public IHttpActionResult UpdateLeadSource(LeadSourceModel model) { var response = new DataResponse <EntityLeadSource>(); if (ModelState.IsValid) { var entityDegree = new EntityLeadSource(); entityDegree.Id = model.Id; entityDegree.IsActive = model.IsActive; entityDegree.LeadSource = model.LeadSource; entityDegree.UpdatedBy = CurrentUserId; entityDegree.UpdatedOn = System.DateTime.UtcNow; response = repository.UpdateLeadSource(entityDegree); return(Ok <DataResponse>(response)); } else { var errorList = ModelState.Where(a => a.Value.Errors.Any()).Select(s => new { Key = s.Key.Split('.').Last(), Message = s.Value.Errors[0].ErrorMessage }); return(Ok <dynamic>(new { Status = HttpStatusCode.BadRequest, Model = errorList })); } }
public DataResponse <EntityLeadSource> UpdateLeadSource(EntityLeadSource entity) { var response = new DataResponse <EntityLeadSource>(); try { base.DBInit(); var model = DBEntity.LookupLeadSources.FirstOrDefault(a => a.Id == entity.Id); model.LeadSource = entity.LeadSource; model.IsActive = entity.IsActive; model.UpdatedOn = entity.UpdatedOn; model.UpdatedBy = entity.UpdatedBy; if (base.DBSaveUpdate(model) > 0) { return(GetLeadsourceById(model.Id)); } else { response.CreateResponse(DataResponseStatus.InternalServerError); } } catch (Exception ex) { ex.Log(); } finally { base.DBClose(); } return(response); }
public DataResponse <EntityLeadSource> Insert(EntityLeadSource entity) { var response = new DataResponse <EntityLeadSource>(); try { base.DBInit(); var model = new Database.LookupLeadSource { LeadSource = entity.LeadSource, CreatedBy = entity.CreatedBy, CreatedOn = System.DateTime.UtcNow, IsActive = entity.IsActive }; if (base.DBSave(model) > 0) { entity.Id = model.Id; response.CreateResponse(entity, DataResponseStatus.OK); } else { response.CreateResponse(DataResponseStatus.InternalServerError); } } catch (Exception ex) { ex.Log(); } finally { base.DBClose(); } return(response); }