Ejemplo n.º 1
0
        private void HandleSaveCommand(object parameter)
        {
            var          result = string.Empty;
            OfferPostDto newOffer;

            try
            {
                newOffer = new OfferPostDto
                {
                    Id          = this.Id,
                    CreatorId   = creatorId,
                    ClientId    = this.SelectedClient.Id,
                    InquiryId   = this.SelectedInquiry.Id,
                    Description = this.Description,
                    Date        = this.Date
                };
                if (this.SelectedOffer == null)
                {
                    result = this.OfferService.CreateOffer(newOffer);
                    MessageBox.Show(result);
                    this.RedirectToMainOffers();
                }
                else
                {
                    result = this.OfferService.EditOffer(newOffer);
                    MessageBox.Show(result);
                    this.RedirectToMainOffers();
                }
            }
            catch (Exception e)
            {
                result = e.Message;
                MessageBox.Show(result);
            }
        }
Ejemplo n.º 2
0
        public string EditOffer(OfferPostDto newOffer)
        {
            var offer = bmsData.Offers.Find(newOffer.Id);

            offer.InquiryId    = newOffer.InquiryId;
            offer.CreatorId    = newOffer.CreatorId;
            offer.ContragentId = newOffer.ClientId;
            offer.Description  = newOffer.Description;
            offer.Date         = newOffer.Date;

            this.bmsData.Offers.Update(offer);
            this.bmsData.SaveChanges();

            return($"Offer with Id: {newOffer.Id} successfully updated!");
        }
Ejemplo n.º 3
0
        public string CreateOffer(OfferPostDto newOffer)
        {
            var offer = new Offer()
            {
                ContragentId = newOffer.ClientId,
                CreatorId    = newOffer.CreatorId,
                InquiryId    = newOffer.InquiryId,
                Description  = newOffer.Description,
                Date         = newOffer.Date
            };

            this.bmsData.Offers.Add(offer);
            this.bmsData.SaveChanges();

            return($"Offer \"{newOffer.Description}\" from date {newOffer.Date.ToShortDateString()} successfully created!");
        }