public void DeleteQuote(Quote Quote)
        {
            try
            {
                context.Quotes.Attach(Quote);
                context.Entry(Quote).State = EntityState.Deleted;
                SaveChanges();
            }
            catch (OptimisticConcurrencyException ex)
            {

                throw ex;
            }
        }
        public long UpdateQuote(Quote Quote)
        {
            try
            {

                var currentQuote = context.Quotes.Find(Quote.QuoteID);
                context.Entry(currentQuote).CurrentValues.SetValues(Quote);
                //Quote.ModifiedTime = DateTime.Now;
                // context.Entry(Quote).State=EntityState.Modified;

                SaveChanges();
                return Quote.QuoteID;
            }
            catch (OptimisticConcurrencyException ex)
            {

                throw ex;
            }
        }
        public long InsertQuote(Quote Quote)
        {
            try
            {

                Quote.CreatedTime = DateTime.Now;
                Quote.ModifiedTime = DateTime.Now;
                context.Entry(Quote).State = EntityState.Added;
                context.SaveChanges();
                return Quote.QuoteID;
            }
            catch (OptimisticConcurrencyException ex)
            {

                throw ex;
            }
        }
Beispiel #4
0
 public void DeleteQuote(Quote Quote)
 {
     quoteRepository.DeleteQuote(Quote);
 }
Beispiel #5
0
        private void ValidateQuote(Quote Quote)
        {
            if (Quote.QuoteNumber != null)
            {
                int companyid = Convert.ToInt32(HttpContext.Current.Session["CompanyID"]);
                var duplicateQuote = quoteRepository.GetLeadByContactID(Quote.QuoteNumber, companyid).FirstOrDefault();
                if (duplicateQuote != null && duplicateQuote.QuoteID != Quote.QuoteID)
                {
                    if (duplicateQuote.QuoteNumber == Quote.QuoteNumber)
                    {
                        throw new DuplicateLeadException(String.Format(
                        "Quote Number {0} is already exist",
                        duplicateQuote.QuoteNumber
                        ));
                    }
                    //else if(Quote.Name==null && Quote.QuoteNumber==null)

                    //{
                    //    throw new DuplicateLeadException(String.Format(
                    //   "A Quote can't create without a product, Select a product"

                    //   ));
                    //}

                }
            }
            else
            {
                throw new DuplicateLeadException(String.Format(
                    "A Quote can't create without a product, Select a product"
                                                     ));
            }
        }
Beispiel #6
0
        public long UpdateQuote(Quote Quote)
        {
            ValidateQuote(Quote);
            try
            {
                return quoteRepository.UpdateQuote(Quote);

            }
            catch (Exception ec)
            {

                throw ec;
            }
        }
Beispiel #7
0
        public long InsertQuote(Quote Quote)
        {
            ValidateQuote(Quote);
            try
            {
                return quoteRepository.InsertQuote(Quote);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }