public OperationResult CreateDeliveryPlace(ServiceDataContracts.DeliveryPlace deliveryPlace) { try { var dbContext = new AlohaDb(); var dp = new Entities.DeliveryPlace(); dp.Name = deliveryPlace.Name; dp.Phone = deliveryPlace.Phone; dp.IsActive = deliveryPlace.IsActive; dbContext.DeliveryPlace.Add(dp); dbContext.SaveChanges(); return(new OperationResult { Success = true, CreatedObjectId = dp.Id }); } catch (Exception e) { log.Error("Error", e); return(new OperationResult { Success = false, ErrorMessage = e.Message }); } }
public OperationResult UpdateDeliveryPlace(ServiceDataContracts.DeliveryPlace deliveryPlace) { var dp = db.DeliveryPlace.FirstOrDefault(p => p.Id == deliveryPlace.Id); if (dp == null) { return(new OperationResult { Success = false, ErrorMessage = "Delivery Place Not Found." }); } dp.Name = deliveryPlace.Name; dp.Phone = deliveryPlace.Phone; dp.IsActive = deliveryPlace.IsActive; db.SaveChanges(); return(new OperationResult { Success = true }); }