NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

//////////////MVC Controller

public class DivisionController : Controller
{
private readonly IDivisionCodeService divisionCodeService;
private readonly IToastNotification toastNotification;

public DivisionController(IDivisionCodeService divisionCodeService, IToastNotification toastNotification)
{
this.divisionCodeService = divisionCodeService;
this.toastNotification = toastNotification;
}

/// <summary>
/// Get Division Code List
/// </summary>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<IActionResult> Index()
{
try
{
var res = await divisionCodeService.GetDivisionCodeListAPI();
if (res != null)
{
return View(res);
}
else
{
var msg = AppResource.ListNotFound;
return Json(msg);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
throw;
}
}

/// <summary>
/// Show popup Add Deduction Code
/// </summary>
/// <returns></returns>
[HttpGet]
[Authorize]
public IActionResult DivisionCode()
{
return PartialView(APIUrls.AddDivisionCode);
}

/// <summary>
/// Add Update Division Code
/// </summary>
/// <param name="divisionCodeViewModel"></param>
/// <returns></returns>
[HttpPost]
[Authorize]
public async Task<IActionResult> AddUpdateDivisionCode(DivisionCodeViewModel divisionCodeViewModel)
{
ResponseModel responseModel = new ResponseModel();
try
{
if (ModelState.IsValid)
{
ApiResponseModel model = new ApiResponseModel();
if (divisionCodeViewModel != null)
{
var createdBy = Convert.ToInt32(HttpContext.Session.GetString(AppConstants.UserId));
divisionCodeViewModel.CreatedBy = createdBy;
if (!String.IsNullOrEmpty(Convert.ToString(divisionCodeViewModel.Id)))
{
var result = await divisionCodeService.InsertDivisionCodeAPI(divisionCodeViewModel);
if (result != null)
{
toastNotification.AddSuccessToastMessage(AppResource.UpdateSuccessfully);
return Json(result);
}
}
else
{
ViewBag.InvalidMsg = AppResource.SomethingWrong;
return View(responseModel);
}
}
}
else
{
ViewBag.InvalidMsg = AppResource.SomethingWrong;
return View(responseModel);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
throw;
}
return View(responseModel);
}

/// <summary>
/// Division Code By Id
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<IActionResult> DivisionCodeById(int Id)
{
DivisionCodeViewModel model = new DivisionCodeViewModel();
try
{
var result = await divisionCodeService.GetDivisionCodeById(Id);
model = result;
}
catch (Exception)
{
return View(AppConstants.Error);
}
return PartialView(APIUrls.UpdateDivisionCode, model);
}

/// <summary>
/// Show popup Deactivate Division Code
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<IActionResult> DeleteDivisionCodeById(int Id)
{
DivisionCodeViewModel model = new DivisionCodeViewModel();
try
{
var result = await divisionCodeService.GetDivisionCodeById(Id);
model = result;
}
catch (Exception)
{
return View(AppConstants.Error);
}
return PartialView(APIUrls.DeleteDivisionCode, model);
}

/// <summary>
/// Deactivate Division Code
/// </summary>
/// <param name="divisionCodeViewModel"></param>
/// <returns></returns>
[HttpPost]
[Authorize]
public async Task<IActionResult> DeleteDivisionCode(DivisionCodeViewModel divisionCodeViewModel)
{
ResponseModel responseModel = new ResponseModel();
try
{
if (ModelState.IsValid)
{
ApiResponseModel model = new ApiResponseModel();
if (divisionCodeViewModel != null)
{
if (!String.IsNullOrEmpty(Convert.ToString(divisionCodeViewModel.Id)))
{
var result = await divisionCodeService.DeleteDivisionCodeAPI(divisionCodeViewModel);
if (result.Status == AppConstants.True)
{
toastNotification.AddSuccessToastMessage(AppResource.DeleteSuccessfully);
}
else
{
toastNotification.AddErrorToastMessage(AppResource.SomethingWrong);
}
return Json(result);
}
else
{
ViewBag.InvalidMsg = AppResource.SomethingWrong;
return View(responseModel);
}
}
}
else
{
ViewBag.InvalidMsg = AppResource.SomethingWrong;
return View(responseModel);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
throw;
}
return View(responseModel);
}

/// <summary>
/// Show popup Activate Division Code
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<IActionResult> ActivateDivisionCodeById(int Id)
{
DivisionCodeViewModel model = new DivisionCodeViewModel();
try
{
var result = await divisionCodeService.GetDivisionCodeById(Id);
model = result;
}
catch (Exception)
{
return View(AppConstants.Error);
}
return PartialView(APIUrls.ActivateDivisionCode, model);
}

/// <summary>
/// Activate Division Code
/// </summary>
/// <param name="divisionCodeViewModel"></param>
/// <returns></returns>
[HttpPost]
[Authorize]
public async Task<IActionResult> ActivateDivisionCode(DivisionCodeViewModel divisionCodeViewModel)
{
ResponseModel responseModel = new ResponseModel();
try
{
if (ModelState.IsValid)
{
ApiResponseModel model = new ApiResponseModel();
if (divisionCodeViewModel != null)
{
if (!String.IsNullOrEmpty(Convert.ToString(divisionCodeViewModel.Id)))
{
var result = await divisionCodeService.ActivateDivisionCodeAPI(divisionCodeViewModel);
return Json(result);
}
else
{
ViewBag.InvalidMsg = AppResource.SomethingWrong;
return View(responseModel);
}
}
}
else
{
ViewBag.InvalidMsg = AppResource.SomethingWrong;
return View(responseModel);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
throw;
}
return View(responseModel);
}
}

//////////////////////Service
/// <summary>
/// Get Costos Employee Detail List
/// </summary>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<DivisionCodeMasterModel> GetDivisionCodeListAPI()
{
try
{
DivisionCodeMasterModel divisionCode = new DivisionCodeMasterModel();
var apiUrl = AppURL.GetDivisionCodeList;
var content = new StringContent(JsonConvert.SerializeObject(divisionCode), Encoding.UTF8, AppURL.ApplicationJsonURL);

using (var response = await Client.GetAsync(apiUrl))

if (response.StatusCode == HttpStatusCode.OK)
{
string apiresonse = await response.Content.ReadAsStringAsync();
divisionCode = JsonConvert.DeserializeObject<DivisionCodeMasterModel>(apiresonse.ToString());
}
return divisionCode;
}
catch (HttpRequestException ex)
{
throw new Exception(AppConstants.APIErrorCalling + ex.Message);
}
}

/// <summary>
/// Insert Division Code API
/// </summary>
/// <param name="divisionCodeViewModel"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<ResponseModel> InsertDivisionCodeAPI(DivisionCodeViewModel divisionCodeViewModel)
{
ResponseModel responseModel = new ResponseModel();
try
{
var content = new StringContent(JsonConvert.SerializeObject(responseModel), Encoding.UTF8, AppURL.ApplicationJsonURL);

using (var response = await Client.PostAsJsonAsync<DivisionCodeViewModel>(AppURL.InserDivisionCode, divisionCodeViewModel))

if (response.StatusCode == HttpStatusCode.OK)
{
string apiresonse = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
var result = JsonConvert.DeserializeObject<bool>(apiresonse.ToString());
responseModel.Status = result.ToString();
}
return responseModel;
}
catch (HttpRequestException ex)
{
throw new Exception(AppConstants.APIErrorCalling + ex.Message);
}
}

/// <summary>
/// Deactivate Division Code API
/// </summary>
/// <param name="divisionCodeViewModel"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<ResponseModel> DeleteDivisionCodeAPI(DivisionCodeViewModel divisionCodeViewModel)
{
ResponseModel responseModel = new ResponseModel();
try
{
var content = new StringContent(JsonConvert.SerializeObject(responseModel), Encoding.UTF8, AppURL.ApplicationJsonURL);

using (var response = await Client.PostAsJsonAsync<DivisionCodeViewModel>(AppURL.DeleteDivisionCode, divisionCodeViewModel))

if (response.StatusCode == HttpStatusCode.OK)
{
string apiresonse = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
var result = JsonConvert.DeserializeObject<bool>(apiresonse.ToString());
responseModel.Status = result.ToString();
}
return responseModel;
}
catch (HttpRequestException ex)
{
throw new Exception(AppConstants.APIErrorCalling + ex.Message);
}
}

/// <summary>
/// Activate Division Code API
/// </summary>
/// <param name="divisionCodeViewModel"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<ResponseModel> ActivateDivisionCodeAPI(DivisionCodeViewModel divisionCodeViewModel)
{
ResponseModel responseModel = new ResponseModel();
try
{
var content = new StringContent(JsonConvert.SerializeObject(responseModel), Encoding.UTF8, AppURL.ApplicationJsonURL);

using (var response = await Client.PostAsJsonAsync<DivisionCodeViewModel>(AppURL.ActivateDivisionCode, divisionCodeViewModel))

if (response.StatusCode == HttpStatusCode.OK)
{
string apiresonse = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
var result = JsonConvert.DeserializeObject<bool>(apiresonse.ToString());
responseModel.Status = result.ToString();
}
return responseModel;
}
catch (HttpRequestException ex)
{
throw new Exception(AppConstants.APIErrorCalling + ex.Message);
}
}

/// <summary>
/// Get Division Code By Id
/// </summary>
/// <param name="employeeId"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task<DivisionCodeViewModel> GetDivisionCodeById(int Id)
{
try
{
DivisionCodeViewModel divisionCode = new DivisionCodeViewModel();
var apiUrl = AppURL.GetDivisionCodeById + Id;
var content = new StringContent(JsonConvert.SerializeObject(divisionCode), Encoding.UTF8, AppURL.ApplicationJsonURL);

using (var response = await Client.GetAsync(apiUrl))

if (response.StatusCode == HttpStatusCode.OK)
{
string apiresonse = await response.Content.ReadAsStringAsync();
divisionCode = JsonConvert.DeserializeObject<DivisionCodeViewModel>(apiresonse.ToString());
}
return divisionCode;
}
catch (HttpRequestException ex)
{
throw new Exception(AppConstants.APIErrorCalling + ex.Message);
}
}

///////////////List Bind
/// <summary>
/// Bind GetCompanyList Lists
/// </summary>
/// <returns></returns>
public async Task<SelectList> GetCompanyList()
{
try
{
SelectList Company;
var list = await dbContext.Company.Where(x => x.IsActive == true).Select(p => new { Id = p.CompanyCode, Name = p.CompanyName }).OrderBy(x => x.Id).ToListAsync();
Company = new SelectList(list, AppConstants.Id, AppConstants.Name);
return Company;
}
catch (Exception ex)
{
Log.Error(ex.Message);
throw;
}
}
////////////ApiResponseModel/// <summary>
/// Get Invoice For Salaried Employee
/// </summary>
/// <param name="startDate"></param>
/// <param name="endDate"></param>
/// <param name="companyId"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<ActionResult> GetInvoiceForSalariedEmployee(string startDate, string endDate, string companyId)
{
try
{
var invoiceForSalariedEmployee = await invoiceRepository.GetSalariedEmployeeListForInvoice(startDate, endDate, companyId);
invoiceForSalariedEmployee.CompanyList = await invoiceRepository.GetCompanyList();
if (invoiceForSalariedEmployee != null)
{
return Ok(invoiceForSalariedEmployee);
}
return BadRequest();
}
catch (Exception exceptions)
{
return BadRequest(exceptions.Message);
}
}
///////////////
@Html.DropDownListFor(model => model.CompanyList, new SelectList(Model.CompanyList?.Items, "Value", "Text"), new { @id = "salaryInvoiceCompanyName", @class = "form-select twice-week date", @required = "true" })
////////////////////
public class InvoiceMasterModelForSalariedEmployee
{
public InvoiceMasterModelForSalariedEmployee()
{
InvoiceModelListForSalariedEmployee = new List<InvoiceModelForSalariedEmployee>();
}
public List<InvoiceModelForSalariedEmployee>? InvoiceModelListForSalariedEmployee { get; set; }

public SelectList? CompanyList { get; set; }

}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.