public ActionResult AddIncidentType(IncidentTypeRequest incidentTypeRequest) { var result = appDbContex.IncidentTypes.Where(a => a.Name == incidentTypeRequest.incidenttypename).FirstOrDefault(); if (result == null) { string id = Guid.NewGuid().ToString(); IncidentType incidentType = new IncidentType() { Id = id, Name = incidentTypeRequest.incidenttypename }; appDbContex.Add(incidentType); appDbContex.SaveChangesAsync(); return(Ok(new { Message = "Incident Type Added Successfully..!" })); } return(BadRequest(new { Message = "Incident Type Already Exist..!" })); }
public ActionResult updateIncidentType(IncidentTypeRequest incidentTypeRequest) { var incidentname = appDbContex.IncidentTypes.Where(a => a.Name == incidentTypeRequest.incidenttypename && a.Id != incidentTypeRequest.id).SingleOrDefault(); if (incidentname == null) { var incidenttype = appDbContex.IncidentTypes.Where(a => a.Id == incidentTypeRequest.id).SingleOrDefault(); if (incidenttype != null) { incidenttype.Name = incidentTypeRequest.incidenttypename; // country.CountryCode = countryRequest.CountryCode; appDbContex.Update(incidenttype); appDbContex.SaveChangesAsync(); //return new resultmv //{ Status = "Success", Message = "Record updated successfully!" }; return(Ok(new { Message = "Record updated successfully!" })); } return(BadRequest(new { Message = "Record not exixst!" })); } return(BadRequest(new { Message = "Incident Name alredy exixst!" })); }