public string Add(IranGravity entity) { _dbSet.Add(entity); _context.Entry(entity).State = EntityState.Added; int commitResult = _context.SaveChanges(); if (commitResult > 0) { return("New iran gravity record added successfully"); } else { return("Failed"); } }
public string PutIranGravity(IranGravity iranGravity) { string returnGravity; try { returnGravity = _gravityService.Update(iranGravity); } catch (ApplicationException ex) { throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, ReasonPhrase = ex.Message }); } return(returnGravity); }
public string Update(IranGravity entity) { var gravity = _dbSet.Find(entity.Id); if (gravity != null) { gravity.Title = entity.Title; gravity.Location = entity.Location; gravity.Description = entity.Description; } _context.Entry(gravity).State = EntityState.Modified; int commitResult = _context.SaveChanges(); if (commitResult > 0) { return("Iran gravity record updated successfully"); } else { return("Failed"); } }