public IDataResult <Address> GetById(int id) { var result = BusinessRules.Run(CheckIfEntityIdValid(id)); if (result == null) { return(new SuccessDataResult <Address>(_addressDal.Get(c => c.Id == id), BusinessMessages.AddressDetailsListed)); } return(new ErrorDataResult <Address>()); }
public HttpResponseMessage ConfirmOrder([FromBody] ConfirmOrderDto codto) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Hatali model!")); } string cookie = codto.Cookie; User user = _userDal.GetUserByCookie(cookie); if (user == null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "User Bulunamadı!")); } List <List <int> > sepetArray = JsonConvert.DeserializeObject <List <List <int> > >(codto.OrderArray); int addressID = codto.AddressID; int regionID = _addressDal.Get(x => x.ID == addressID).RegionID; int companyID = sepetArray[0][2]; int branchID = _branchDal.Get(x => x.CompanyID == companyID && x.RegionID == regionID).ID; bool paymentType = codto.PaymentType == 0; decimal totalPrice = 0; int orderCount = sepetArray.Count; for (int i = 0; i < orderCount; i++) { totalPrice += (_menuDal.GetByID(sepetArray[i][0]).Price) * sepetArray[i][1]; } Order o = new Order() { BranchID = branchID, AddressID = addressID, IsActive = true, OrderDate = DateTime.Now, PaymentType = paymentType, TotalPrice = totalPrice }; _orderDal.Add(o); for (int i = 0; i < orderCount; i++) { OrderDetail od = new OrderDetail() { IsCompleted = true, MenuID = sepetArray[i][0], OrderID = o.ID, Quantity = sepetArray[i][1], TotalAmount = _menuDal.GetByID(sepetArray[i][0]).Price *sepetArray[i][1] }; _orderDetailDal.Add(od); } return(Request.CreateResponse(HttpStatusCode.OK, "Başarılı")); }
public IDataResult <Address> GetById(int addressId) { return(new SuccessDataResult <Address>(_addressDal.Get(c => c.AddressId == addressId), Messages.AddressListed)); }
public IDataResult <Address> GetByCustomerId(int customerId) { return(new SuccessDataResult <Address>(_addressDal.Get(address => address.CustomerId == customerId))); }
public IDataResult <Address> GetById(int addressId) { return(new SuccessDataResult <Address>(_addressDal.Get(a => a.Id == addressId))); }
public void Delete(int id) { var value = _addressDal.Get(x => x.Id == id); _addressDal.Delete(value); }
public Addresses Get(Expression <Func <Addresses, bool> > filter = null) { return(_addressDal.Get(filter)); }
public IDataResult <Address> GetByUserId(int userId) { return(new SuccessDataResult <Address>(_addressDal.Get(c => c.Id == userId))); }