public async Task <ActionResult <Sale> > PostSale(Sale sale) { _repository.Add(sale); await _repository.SaveChangesAsync(); return(CreatedAtAction("GetSale", new { id = sale.Id }, sale)); }
public bool TryAddSaleWithId(Sale sale) { ResolveLocker(typeof(Sale)).EnterWriteLock(); try { var clientId = sale.Client.Id; Expression <Func <Item, bool> > itemSearchCriteria = x => x.Name == sale.Item.Name; var itemId = GetEntityId(itemSearchCriteria, ItemRepository); var dataSourceId = sale.DataSource.Id; SaleRepository.Add(new EF.Sale { Date = sale.Date, SaleSum = sale.SaleSum, ClientId = clientId, DataSourceId = dataSourceId, ItemId = itemId }); SaleRepository.Save(); return(true); } catch (Exception) { throw new ObjectAdditionException(sale); } finally { ResolveLocker(typeof(Sale)).ExitWriteLock(); } }
public IActionResult Sale(Sale sale) { var currentUser = GetCurrentUserProfile(); sale.UserProfileId = currentUser.Id; _saleRepo.Add(sale); return(CreatedAtAction("Get", new { id = sale.Id }, sale)); }
public INotificationHandler Process(string value) { var recordType = value.Substring(0, 3); var record = value.Remove(0, 4); switch (recordType) { case "001": return(vendorRepository.Add(vendorParser.Parse(record))); case "002": return(customerRepository.Add(customerParser.Parse(record))); case "003": return(saleRepository.Add(saleParser.Parse(record))); default: throw new ArgumentOutOfRangeException("Invalid record type!"); } }
public bool TryAddSale(Sale sale, Expression <Func <Sale, bool> > searchExpression) { ResolveLocker(typeof(Sale)).EnterWriteLock(); try { var searchedSale = GetEntity(searchExpression, SaleRepository); if (searchedSale != null) { return(false); } Expression <Func <Client, bool> > clientSearchCriteria = x => x.FirstName == sale.Client.FirstName && x.LastName == sale.Client.LastName; var clientId = GetEntityId(clientSearchCriteria, ClientRepository); Expression <Func <Item, bool> > itemSearchCriteria = x => x.Name == sale.Item.Name; var itemId = GetEntityId(itemSearchCriteria, ItemRepository); Expression <Func <DataSource, bool> > dataSourcetSearchCriteria = x => x.FileName == sale.DataSource.FileName; var dataSourceId = GetEntityId(dataSourcetSearchCriteria, DataSourceRepository); SaleRepository.Add(new EF.Sale { Date = sale.Date, SaleSum = sale.SaleSum, ClientId = clientId, DataSourceId = dataSourceId, ItemId = itemId }); SaleRepository.Save(); return(true); } catch (Exception) { throw new ObjectAdditionException(sale); } finally { ResolveLocker(typeof(Sale)).ExitWriteLock(); } }
public JsonResult Add(ProductSold sale) { return(Json(saleRepository.Add(sale), JsonRequestBehavior.AllowGet)); }
public void CrateNewSale(ISale sale) { SaleRepository.Add(sale); }
public ActionResult ConfirmReservation(int movieID, int saloonID, int sessionID, int genreID, string ticketPrice, string seats) { decimal toBeConverted = Convert.ToDecimal(ticketPrice); var query = _saleRep.FirstOrDefault(x => x.MovieID == movieID && x.SessionID == sessionID && x.GenreID == genreID && x.TicketPrice == toBeConverted); ViewBag.Seats = seats; if (query == null) { int userID = 0; if (Session["member"] != null) { userID = (Session["member"] as AppUser).ID; } else if (Session["vip"] != null) { userID = (Session["vip"] as AppUser).ID; } Sale toBeAdded = new Sale() { AppUserID = userID, MovieID = movieID, SessionID = sessionID, GenreID = genreID, Type = ENTITIES.Enums.PaymentType.JustReservation, SaleType = ENTITIES.Enums.SaleType.Reservation, TicketPrice = Convert.ToDecimal(ticketPrice) }; _saleRep.Add(toBeAdded); string[] selectedSeats = seats.Trim().Split(':'); List <SeatListVM> characterNumber = new List <SeatListVM>(); for (int i = 0; i < selectedSeats.Length; i++) { string[] seat = selectedSeats[i].Split('-'); characterNumber.Add(new SeatListVM { Character = seat[0], Number = Convert.ToInt32(seat[1]) }); } foreach (SeatListVM item in characterNumber) { Seat result = _sRep.FirstOrDefault(x => x.SaloonID == saloonID && x.SessionID == sessionID && x.Character == item.Character && x.Number == item.Number); result.SeatActive = true; _saleSeatRep.Add(new SaleSeat { SaleID = toBeAdded.ID, SeatID = result.ID }); _sRep.Update(result); } SaleResvervationTicketVM srtvm = new SaleResvervationTicketVM() { MovieName = toBeAdded.Movie.MovieName, TicketPrice = Convert.ToDecimal(ticketPrice), SalonID = saloonID, SaleNo = toBeAdded.SaleNo, TicketDate = (_sesRep.FirstOrDefault(x => x.ID == sessionID)).Time }; return(View(srtvm)); } else { SaleResvervationTicketVM svtvm = new SaleResvervationTicketVM() { MovieName = query.Movie.MovieName, TicketPrice = Convert.ToDecimal(ticketPrice), SalonID = saloonID, SaleNo = query.SaleNo, TicketDate = (_sesRep.FirstOrDefault(x => x.ID == sessionID)).Time }; return(View(svtvm)); } }
public bool Add(Sale sale) { return(_saleRepository.Add(sale)); }