Пример #1
0
        public ActionResult AddNewTask(TaskViewModel model)
        {
            BostreamEntities1 db    = new BostreamEntities1();
            List <Task>       tasks = db.Tasks.ToList();

            Task tsk = new Task();

            try
            {
                tsk.Title = model.TaskTitle;
                DateTime date = DateTime.Parse(model.Deadline);
                tsk.Deadline    = date;
                tsk.Priority    = model.Priority;
                tsk.CustomerID  = model.CustomerID;
                tsk.Description = model.Description;

                db.Tasks.Add(tsk);

                db.SaveChanges();
            }

            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(View("NewTask", model));
        }
Пример #2
0
        public ActionResult AddCustomer(CustomerViewModel model)
        {
            var person = new Person
            {
                FirstName = model.FirstName,
                LastName  = model.LastName,
                Email     = model.Email
            };

            var customer = new Customer
            {
                CompanyName = model.CompanyName,
                Phone       = model.Phone,
                Note        = model.Note,
                PersonID    = person.PersonId
            };

            using (var context = new BostreamEntities1())
            {
                context.People.Add(person);
                context.Customers.Add(customer);
                context.SaveChanges();
            }
            return(View("NewCustomer", model));
        }
Пример #3
0
 public ActionResult AddQuotation([Bind(Include = "QuotationID, CustomerID, ServiceID, CreationDate, ExpirationDate, Price")] Quotation _NewQuotation)
 {
     if (ModelState.IsValid)
     {
         BostreamEntities1 db = new BostreamEntities1();
         db.Quotations.Add(_NewQuotation);
         db.SaveChanges();
         return(RedirectToAction("CustomerView"));
     }
     return(View(_NewQuotation));
 }
Пример #4
0
        public ActionResult AddNewQuotation(QuotationViewModel model)
        {
            BostreamEntities1 db    = new BostreamEntities1();
            List <Quotation>  tasks = db.Quotations.ToList();

            Quotation qt = new Quotation();

            try
            {
                qt.CreationDate   = DateTime.Now;
                qt.CustomerID     = model.CustomerID;
                qt.ExpirationDate = model.ExpirationDate;
                qt.Price          = model.Price;
                qt.ServiceID      = model.ServiceID;


                db.Quotations.Add(qt);

                db.SaveChanges();
            }

            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }


            return(View("NewQuotation", model));
        }