public OperationResult CreateCurier(ServiceDataContracts.Curier curier) { try { var dbContext = new AlohaDb(); var c = new Entities.Curier(); c.FullName = curier.FullName; c.Phone = curier.Phone; c.IsActive = curier.IsActive; dbContext.Curiers.Add(c); dbContext.SaveChanges(); return(new OperationResult { Success = true, CreatedObjectId = c.Id }); } catch (Exception e) { log.Error("Error", e); return(new OperationResult { Success = false, ErrorMessage = e.Message }); } }
public OperationResult UpdateCurier(ServiceDataContracts.Curier curier) { var c = db.Curiers.FirstOrDefault(cr => cr.Id == curier.Id); if (c == null) { return(new OperationResult { Success = false, ErrorMessage = "Curier Not Found." }); } c.FullName = curier.FullName; c.Phone = curier.Phone; c.IsActive = curier.IsActive; db.SaveChanges(); return(new OperationResult { Success = true }); }