public void DeleteById(int entityID) { UserTypes usertype = _userTypeDAL.Get(a => a.ID == entityID); _userTypeDAL.Delete(usertype); }
public ActionResult QuickOrder(VMQuickOrder postOrder) { if (ModelState.IsValid) { User newGuest = new User() { UserID = Guid.NewGuid(), IsActive = false, FullName = postOrder.FullName, Email = postOrder.Email, CreatedDate = DateTime.Now, Password = "******", UserTypeID = new Guid("b9b77014-f2a0-4d3c-9c0d-f64b3e36ec6f"), }; UserType guestType = userTypeDAL.Get(x => x.UserTypeName == "guest"); UserDetail guestDetail = new UserDetail() { Gender = false, IsActive = true, Telephone = postOrder.Telephone, UserDetailID = Guid.NewGuid(), UserID = newGuest.UserID }; UserAddress guestAddress = new UserAddress() { UserAddressID = Guid.NewGuid(), Address = postOrder.Address, AddressFullName = "Guest", DistrictID = postOrder.DistrictID, IsActive = true, UserID = newGuest.UserID }; List <BasketProduct> guestBasket = Session["basket"] as List <BasketProduct>; decimal total = 0; foreach (var basket in guestBasket) { decimal unitPrice = basket.Product.UnitPrice; if (basket.Product.Campaigns.Count != 0) { foreach (var camp in basket.Product.Campaigns.Where(x => x.EndingDate > DateTime.Now && x.StartedDate < DateTime.Now && x.IsActive == true)) { unitPrice = unitPrice * (1 - camp.Discount); } } total += (unitPrice * basket.Count); } foreach (var basketProduct in guestBasket) { var product = productDAL.Get(x => x.ProductID == basketProduct.ProductID); product.UnitsInStock -= basketProduct.Count; if (product.UnitsInStock <= 0) { product.IsActive = false; } productDAL.Update(product); } UserCard guestCard = new UserCard() { CardNo = postOrder.CardNo, ExpritionDate = Convert.ToDateTime("01-" + postOrder.Month + "-20" + postOrder.Year), FullName = postOrder.CardFullName, IsActive = true, SecurityCode = postOrder.SecurityCode, UserCardID = Guid.NewGuid(), UserID = newGuest.UserID }; Order guestOrder = new Order() { OrderID = Guid.NewGuid(), UserID = newGuest.UserID, UserCardID = guestCard.UserCardID, AddressID = guestAddress.UserAddressID, UserDetailID = guestDetail.UserDetailID, PaymentTypeID = new Guid("7e4289f3-ce9d-4c3b-847f-710664319e4b"), CreatedTime = DateTime.Now, IsActive = true, OrderStatusID = new Guid("7A75CDFB-52A3-4455-A8C2-08D6DE333E45"), TotalAmount = total }; foreach (var basket in guestBasket) { OrderDetail od = new OrderDetail() { OrderID = guestOrder.OrderID, Count = basket.Count, IsActive = true, ProductID = basket.ProductID }; guestOrder.OrderDetails.Add(od); } newGuest.Orders.Add(guestOrder); newGuest.UserAddresses.Add(guestAddress); newGuest.UserCards.Add(guestCard); newGuest.UserDetails.Add(guestDetail); newGuest.UserType = guestType; userDAL.Add(newGuest); Session["basket"] = null; ViewData["success"] = guestOrder.OrderID.ToString() + " numaralı siparişinizi bu kodu kullanarak takip edebilirsiniz. "; return(View("QuickOrderDetail")); } else { ViewBag.City = cityDAL.GetList().OrderBy(x => x.CityName).ToList(); return(View()); } }