public ActionResult Create(OrderCreateViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     try
     {
         _orderManager.Add(Mapper.Map <OrderCreateViewModel, Order>(model));
         return(RedirectToAction("Index"));
     }
     catch (ValidationException exception)
     {
         model.Pharmacies = new SelectList(_pharmacyManager.FindAll(), "Id", "Number");
         model.Types      = new SelectList(new List <object>()
         {
             new { Id = 2, Value = "Purchase" }, new { Id = 1, Value = "Sale" }
         }, "Id", "Value");
         ModelState.AddModelError("", "Validation data error! Change values!");
         return(View(model));
     }
     catch
     {
         model.Pharmacies = new SelectList(_pharmacyManager.FindAll(), "Id", "Number");
         model.Types      = new SelectList(new List <object>()
         {
             new { Id = 2, Value = "Purchase" }, new { Id = 1, Value = "Sale" }
         }, "Id", "Value");
         ModelState.AddModelError("", "Adding new record error!");
         return(View(model));
     }
 }
 public ActionResult Create(MedicamentViewModel medicamentView)
 {
     if (!ModelState.IsValid)
     {
         return(View(medicamentView));
     }
     try
     {
         var entity  = Mapper.Map <MedicamentViewModel, Medicament>(medicamentView);
         var history = new MedicamentPriceHistory()
         {
             Medicament   = entity,
             MedicamentId = entity.Id,
             ModifiedDate = DateTime.Now,
             Price        = entity.Price
         };
         entity.MedicamentPriceHistories.Add(history);
         _medicamentManager.Add(entity);
         _medicamentManager.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         ModelState.AddModelError("", "Возникла ошибка при добавлении сущьности!");
         return(View(medicamentView));
     }
 }
 public ActionResult Create(StorageCreateViewModel model)
 {
     if (!ModelState.IsValid)
     {
         var listPharmacies = new SelectList(_pharmacyManager.FindAll(), "Id", "Number");
         ViewBag.Pharmacies = listPharmacies;
         var listMedicaments = new SelectList(_medicamentManager.FindAll(), "Id", "Name");
         ViewBag.Medicaments = listMedicaments;
         return(View());
     }
     try
     {
         var entity = Mapper.Map <StorageCreateViewModel, Storage>(model);
         _storageManager.Add(entity);
         _storageManager.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         var listPharmacies = new SelectList(_pharmacyManager.FindAll(), "Id", "Number");
         ViewBag.Pharmacies = listPharmacies;
         var listMedicaments = new SelectList(_medicamentManager.FindAll(), "Id", "Name");
         ViewBag.Medicaments = listMedicaments;
         ModelState.AddModelError("error", "Adding new record error!");
         return(View(model));
     }
 }
Ejemplo n.º 4
0
 public ActionResult Create(OrderDetailsCreateViewModel model)
 {
     if (!ModelState.IsValid)
     {
         var listOrders = new SelectList(_orderManager.FindAll(), "Id", "Id");
         ViewBag.Orders = listOrders;
         var listMedicaments = new SelectList(_medicamentManager.FindAll(), "Id", "Name");
         ViewBag.Medicaments = listMedicaments;
         return(View(model));
     }
     try
     {
         var entity = Mapper.Map <OrderDetailsCreateViewModel, OrderDetails>(model);
         _orderDetailsManager.Add(entity);
         _orderDetailsManager.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         var listOrders = new SelectList(_orderManager.FindAll(), "Id", "Id");
         ViewBag.Orders = listOrders;
         var listMedicaments = new SelectList(_medicamentManager.FindAll(), "Id", "Name");
         ViewBag.Medicaments = listMedicaments;
         ModelState.AddModelError("", "Adding new record error!");
         return(View());
     }
 }
Ejemplo n.º 5
0
 public ActionResult Create(OrderDetailsCreateViewModel model)
 {
     if (!ModelState.IsValid)
     {
         model.Medicaments = new SelectList(_medicamentManager.FindAll(), "Id", "Name");
         model.Orders      = new SelectList(_orderManager.FindAll(), "Id", "Id");
         return(View(model));
     }
     try
     {
         var entity = Mapper.Map <OrderDetailsCreateViewModel, OrderDetails>(model);
         _orderDetailsManager.Add(entity);
         return(RedirectToAction("Index"));
     }
     catch (ValidationException e)
     {
         model.Medicaments = new SelectList(_medicamentManager.FindAll(), "Id", "Name");
         model.Orders      = new SelectList(_orderManager.FindAll(), "Id", "Id");
         ModelState.AddModelError("", "Adding new record error!");
         return(View(model));
     }
     catch
     {
         model.Medicaments = new SelectList(_medicamentManager.FindAll(), "Id", "Name");
         model.Orders      = new SelectList(_orderManager.FindAll(), "Id", "Id");
         ModelState.AddModelError("", "Adding new record error!");
         return(View());
     }
 }
        public ActionResult Create(OrderViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var listPharmacies = new SelectList(_pharmacyManager.FindAll(), "Id", "Number");

            ViewBag.Pharmacies = listPharmacies;
            var listTypes = new SelectList(new List <object>()
            {
                new { Id = 2, Value = "Purchase" }, new { Id = 1, Value = "Sale" }
            }, "Id", "Value");

            ViewBag.OperationTypes = listTypes;
            try
            {
                _orderManager.Add(Mapper.Map <OrderViewModel, Order>(model));
                _orderManager.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch
            {
                ModelState.AddModelError("", "Adding new record error!");
                return(View(model));
            }
        }
Ejemplo n.º 7
0
        private void AddItemButton_Click(object sender, EventArgs e)
        {
            try
            {
                Item item         = new Item();
                Item returnedItem = ShowDialogNewItem(item);

                if (returnedItem != null)
                {
                    if (_itemManager.Add(returnedItem) > 0)
                    {
                        LoadData();
                    }
                    else
                    {
                        string caption = "Error.";
                        string message = "Can't add item. Please try again.";
                        MessageBox.Show(message, caption, MessageBoxButtons.OK);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.log.Error(ex.ToString());
            }
        }
Ejemplo n.º 8
0
        public ActionResult Add([DataSourceRequest] DataSourceRequest request, ProviderViewModel provider)
        {
            if (provider != null && ModelState.IsValid)
            {
                providerManager.Add(provider);
            }

            return(Json(new[] { provider }.ToDataSourceResult(request, ModelState)));
        }
Ejemplo n.º 9
0
        public ActionResult Add([DataSourceRequest] DataSourceRequest request, SaleViewModel sale)
        {
            if (sale != null && ModelState.IsValid)
            {
                saleManager.Add(sale);
            }

            return(Json(new[] { sale }.ToDataSourceResult(request, ModelState)));
        }
Ejemplo n.º 10
0
 public bool AddManager(Player playerInfo)
 {
     if (Validate(playerInfo))
     {
         _IManager.Add(playerInfo);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 11
0
        public ActionResult Add([DataSourceRequest] DataSourceRequest request, ClientViewModel client)
        {
            if (client != null && ModelState.IsValid)
            {
                clientManager.Add(client);
            }

            return(Json(new[] { client }.ToDataSourceResult(request, ModelState)));
        }
        public void SendToBank(DirectoryInfo source)
        {
            folderCreator.Create(source);

            if (carrier.Transfer(folderCreator.Directory, drawings))
            {
                manager.Add(folderCreator.Directory.Name, drawings);
                Clear();
            }
        }
 public static void SetManager(IManager <ImportProcess> manager)
 {
     _Manager = manager;
     if (catchItems != null)
     {
         foreach (ImportProcess var in catchItems)
         {
             _Manager.Add(var);
         }
     }
     catchItems.Clear();
 }
Ejemplo n.º 14
0
 public static void SetManager(IManager <IColumnItem> manager)
 {
     _Manager = manager;
     if (catchItems != null)
     {
         foreach (IColumnItem var in catchItems)
         {
             _Manager.Add(var);
         }
     }
     catchItems.Clear();
 }
Ejemplo n.º 15
0
 public static void SetManager(IManager <ButtonAdapter> manager)
 {
     _Manager = manager;
     if (catchItems != null)
     {
         foreach (ButtonAdapter var in catchItems)
         {
             _Manager.Add(var);
         }
     }
     catchItems.Clear();
 }
 public static void SetManager(IManager <ControlContainer> manager)
 {
     _Manager = manager;
     if (catchItems != null)
     {
         foreach (ControlContainer var in catchItems)
         {
             _Manager.Add(var);
         }
     }
     catchItems.Clear();
 }
Ejemplo n.º 17
0
 /// <summary>
 /// 新增學生相關右鍵選單按鈕
 /// </summary>
 public static void AddItem(ButtonAdapter item)
 {
     if (_Manager == null)
     {
         if (catchItems == null)
         {
             catchItems = new List <ButtonAdapter>();
         }
         catchItems.Add(item);
     }
     else
     {
         _Manager.Add(item);
     }
 }
Ejemplo n.º 18
0
 public ActionResult Create(MedicamentPriceHistoryViewModel model)
 {
     if (!ModelState.IsValid) return View(model);
     try
     {
         var entity = Mapper.Map<MedicamentPriceHistoryViewModel, MedicamentPriceHistory>(model);
         _medicamentPriceHistoryManager.Add(entity);
         return RedirectToAction("Index");
     }
     catch
     {
         ModelState.AddModelError("", "Error to create new record");
         return View(model);
     }
 }
 /// <summary>
 /// 新增匯入課程相關流程
 /// </summary>
 public static void AddProcess(ImportProcess process)
 {
     if (_Manager == null)
     {
         if (catchItems == null)
         {
             catchItems = new List <ImportProcess>();
         }
         catchItems.Add(process);
     }
     else
     {
         _Manager.Add(process);
     }
 }
 /// <summary>
 /// 新增課程相關右鍵選單控制項
 /// </summary>
 public static void AddItem(ControlContainer item)
 {
     if (_Manager == null)
     {
         if (catchItems == null)
         {
             catchItems = new List <ControlContainer>();
         }
         catchItems.Add(item);
     }
     else
     {
         _Manager.Add(item);
     }
 }
Ejemplo n.º 21
0
 /// <summary>
 /// 新增課程的延伸資料行
 /// </summary>
 public static void AddItem(IColumnItem item)
 {
     if (_Manager == null)
     {
         if (catchItems == null)
         {
             catchItems = new List <IColumnItem>();
         }
         catchItems.Add(item);
     }
     else
     {
         _Manager.Add(item);
     }
 }
Ejemplo n.º 22
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxMiddleName.Text) || string.IsNullOrWhiteSpace(textBoxLastName.Text) ||
                    string.IsNullOrWhiteSpace(textBoxAddress.Text) || string.IsNullOrWhiteSpace(textBoxEmail.Text) || string.IsNullOrWhiteSpace(textBoxPhone.Text) ||
                    Controls.OfType <RadioButton>().FirstOrDefault(x => x.Checked) == null)
                {
                    string       message = "All fields must be fill up.";
                    string       caption = "Please try again.";
                    DialogResult result  = MessageBox.Show(message, caption, MessageBoxButtons.OK);
                }
                else
                {
                    Customer customer = new Customer();
                    customer.FirstName  = textBoxFirstName.Text;
                    customer.MiddleName = textBoxMiddleName.Text;
                    customer.LastName   = textBoxLastName.Text;
                    customer.Gender     = Controls.OfType <RadioButton>().FirstOrDefault(x => x.Checked).Text;
                    customer.ContactNo  = textBoxPhone.Text;
                    customer.Email      = textBoxEmail.Text;
                    customer.Address    = textBoxAddress.Text;

                    if ((customer.Id = _manager.Add(customer)) > 0)
                    {
                        _success = true;
                        CustomerForm customerForm = Application.OpenForms.OfType <CustomerForm>().FirstOrDefault();
                        customerForm.LoadData();

                        ProfileForm profileForm = new ProfileForm(customer.Id);
                        profileForm.MdiParent = this.ParentForm;
                        profileForm.Show();
                        this.Close();
                    }
                    else
                    {
                        string       message = string.Empty;
                        string       caption = "Please try again.";
                        DialogResult result  = MessageBox.Show(message, caption, MessageBoxButtons.OK);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.log.Error(ex.ToString());
            }
        }
Ejemplo n.º 23
0
        private void AddToCartButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (itemListView.CheckedItems.Count > 0)
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        foreach (ListViewItem listViewItem in itemListView.CheckedItems)
                        {
                            Item         item         = _itemManager.GetById(listViewItem.SubItems[1].Text.ToInt(-1));
                            PurchaseItem purchaseItem = new PurchaseItem {
                                PurchaseId = _purchase.Id, ItemId = item.Id, Price = item.Price, Quantity = 1, SubTotal = item.Price
                            };
                            item.Stocks -= 1;

                            if ((purchaseItem.Id = _purchaseItemManager.Add(purchaseItem)) > 0 && _itemManager.Update(item))
                            {
                                _purchases.Add(new PurchaseDetails(purchaseItem, item));
                                LoadData();
                                CartForm cartForm = Application.OpenForms.OfType <CartForm>().FirstOrDefault();
                                cartForm.LoadData();
                            }
                            else
                            {
                                string caption = "Can't add item(s).";
                                string message = "Please try again.";
                                MessageBox.Show(message, caption, MessageBoxButtons.OK);
                                return;
                            }
                        }

                        scope.Complete();
                    }
                }
                else
                {
                    string caption = "No item selected.";
                    string message = "Please select an item to be added in your cart.";
                    MessageBox.Show(message, caption, MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                Logger.log.Error(ex.ToString());
            }
        }
Ejemplo n.º 24
0
 public ActionResult Create(CustomerViewModel customerViewModel)
 {
     try
     {
         // TODO: Add insert logic here
         if (!ModelState.IsValid)
         {
             return(View(customerViewModel));
         }
         _manager.Add(Mapper.Map <CustomerViewModel, Customer>(customerViewModel));
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 25
0
 public ActionResult Create(DepartmentViewModel departmentViewModel)
 {
     try
     {
         // TODO: Add insert logic here
         if (!ModelState.IsValid)
         {
             return(View(departmentViewModel));
         }
         _manager.Add(Mapper.Map <DepartmentViewModel, Department>(departmentViewModel));
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(EquipmentContractViewModel equipmentContractViewModel)
 {
     try
     {
         // TODO: Add insert logic here
         if (!ModelState.IsValid)
         {
             return(View(equipmentContractViewModel));
         }
         _manager.Add(Mapper.Map <EquipmentContractViewModel, EquipmentContract>(equipmentContractViewModel));
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(MedicamentViewModel medicamentView)
 {
     if (!ModelState.IsValid)
     {
         return(View(medicamentView));
     }
     try
     {
         var entity = Mapper.Map <MedicamentViewModel, Medicament>(medicamentView);
         _medicamentManager.Add(entity);
         return(RedirectToAction("Index"));
     }
     catch
     {
         ModelState.AddModelError("", "Возникла ошибка при добавлении сущьности!");
         return(View(medicamentView));
     }
 }
Ejemplo n.º 28
0
 public async Task <IActionResult> Post([FromBody] Category value)
 {
     try
     {
         if (await _manager.Add(value))
         {
             return(Ok());
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception e)
     {
         return(BadRequest());
     }
 }
 public ActionResult Create(EmployeeViewModel employeeViewModel)
 {
     try
     {
         // TODO: Add insert logic here
         if (!ModelState.IsValid)
         {
             ViewBag.Departments = Departments;
             return(View(employeeViewModel));
         }
         _manager.Add(Mapper.Map <EmployeeViewModel, Employee>(employeeViewModel));
         return(RedirectToAction("Index"));
     }
     catch
     {
         ViewBag.Departments = Departments;
         return(View());
     }
 }
Ejemplo n.º 30
0
 public ActionResult Create(PharmacyViewModel pharmacyView)
 {
     if (!ModelState.IsValid)
     {
         return(View(pharmacyView));
     }
     try
     {
         var pharmacy = Mapper.Map <PharmacyViewModel, Pharmacy>(pharmacyView);
         _manager.Add(pharmacy);
         _manager.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         ModelState.AddModelError("", "Ошибка добавления данных");
         return(View(pharmacyView));
     }
 }