public async Task <Response> RemoveContractType(ContractTypeVM contracttype) { try { var DTO = await _db.ContractTypes.Where(x => x.Id == contracttype.Id).FirstOrDefaultAsync(); _db.ContractTypes.Remove(DTO); int result = await _db.SaveChangesAsync(); if (result == 1) { // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>()); return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result)); } else { return(GenericResponses <int> .ResponseStatus(true, Constant.MSGFailed, (int)Constant.httpStatus.NoContent, result)); } } catch (Exception e) { return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0)); } }
public async Task <JsonResult> RemoveContractType(ContractTypeVM contracttype) { Response r = await Repository.RemoveContractType(contracttype); // List<UserVM> employees = ((IEnumerable)r.Value).Cast<UserVM>().ToList(); ; return(Json(r, JsonRequestBehavior.AllowGet)); }
public async Task <Response> AddContractType(ContractTypeVM contracttype) { var Dto = Mapper.Map <ContractTypeVM, ContractType>(contracttype); ContractType Exist = await _db.ContractTypes.Where(x => x.Type.Trim() == contracttype.Type.Trim()).FirstOrDefaultAsync(); if (Exist != null) { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, 0)); } _db.ContractTypes.Add(Dto); int result = await _db.SaveChangesAsync(); if (result == 1) { // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>()); return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result)); } else { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result)); } }
public async Task <JsonResult> AddContractType(ContractTypeVM contracttype) { contracttype.CreatedOn = DateTime.Today; contracttype.EcomID = (int)Session["Comp"]; Response r = await Repository.AddContractType(contracttype); // List<UserVM> employees = ((IEnumerable)r.Value).Cast<UserVM>().ToList(); ; return(Json(r, JsonRequestBehavior.AllowGet)); }