Example #1
0
        public static void UpdateManufacture(this Manufacture manufacture, ManufactureViewModel manufactureViewModel)
        {
            manufacture.ManufactureID   = manufactureViewModel.ManufactureID;
            manufacture.ManufactureName = manufactureViewModel.ManufactureName;

            manufacture.Description = manufactureViewModel.Description;
            manufacture.Logo        = manufactureViewModel.Logo;
            manufacture.Url         = manufactureViewModel.Url;
        }
        public IActionResult Put([FromBody] ManufactureViewModel manufacture)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(Response(manufacture));
            }

            _appService.Update(manufacture);

            return(Response("Manufacture successfully updated"));
        }
Example #3
0
        public ActionResult Create(ManufactureViewModel manufactureViewModel)
        {
            if (ModelState.IsValid)
            {
                var manufacturer = Mapper.Map <Manufacturer>(manufactureViewModel);
                manufacturer.Status = Domain.Enum.CommonStatus.Active;
                db.Manufacturers.Add(manufacturer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View());
        }
 public async Task <IActionResult> Update([FromBody] ManufactureViewModel mt)
 {
     try
     {
         return(Ok(await manuRepo.SaveOrUpdate(mt)));
     }
     catch (CustomException cex)
     {
         var returnObj = new EmaintenanceMessage(cex.Message, cex.Type, cex.IsException, cex.Exception?.ToString());
         return(StatusCode(StatusCodes.Status500InternalServerError, returnObj));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, new EmaintenanceMessage(ex.Message)));
     }
 }
        public ActionResult Edit(ManufactureViewModel manufactureViewModel)
        {
            if (ModelState.IsValid)
            {
                Manufacturer manufacturer = db.Manufacturers.Find(manufactureViewModel.Id);
                if (manufacturer == null)
                {
                    return(HttpNotFound());
                }

                Mapper.Map(manufactureViewModel, manufacturer);
                db.Entry(manufacturer).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(manufactureViewModel));
        }
        public ActionResult Edit(string id, ManufactureViewModel model)
        {
            try
            {
                var manufacture = _manufactureService.GetById(new Guid(id));

                manufacture.UpdateManufacture(model);
                manufacture.ManufactureID = new Guid(id);
                _manufactureService.Update(manufacture);
                _manufactureService.SaveChange();
                SetAlert("Updated " + model.ManufactureName + " successfully", "success");
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("edit-brand-err", ex.Message);
                return(View(model));
            }
        }
        public ActionResult Create(ManufactureViewModel model)
        {
            try
            {
                var manufacture = new Manufacture();
                manufacture.UpdateManufacture(model);
                manufacture.ManufactureID = Guid.NewGuid();
                _manufactureService.Add(manufacture);
                _manufactureService.SaveChange();

                SetAlert("AAdded " + model.ManufactureName + " into Manufactures List successfully", "success");

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("create-brand-err", ex.Message);
                return(View(model));
            }
        }
 public async Task <IActionResult> Create([FromBody] ManufactureViewModel mt)
 {
     try
     {
         CurrentUser cUser = new CurrentUser(HttpContext, _configuration);
         mt.UserId         = cUser.UserId;
         mt.ManufacturerId = 0;
         mt.Active         = "Y";
         return(Ok(await manuRepo.SaveOrUpdate(mt)));
     }
     catch (CustomException cex)
     {
         var returnObj = new EmaintenanceMessage(cex.Message, cex.Type, cex.IsException, cex.Exception?.ToString());
         return(StatusCode(StatusCodes.Status500InternalServerError, returnObj));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, new EmaintenanceMessage(ex.Message)));
     }
 }
Example #9
0
        public async Task <IEnumerable <dynamic> > SaveOrUpdate([FromBody] ManufactureViewModel mt)
        {
            string sql = "dbo.EAppSaveManufacturer";

            using (var conn = util.MasterCon())
            {
                try
                {
                    return(await(conn.QueryAsync <dynamic>(sql, new
                    {
                        mt.ManufacturerId,
                        mt.LanguageId,
                        mt.ManufacturerCode,
                        mt.ManufacturerName,
                        mt.Descriptions,
                        mt.Active,
                        mt.BearingMFT,
                        mt.DriveMFT,
                        mt.IntermediateMFT,
                        mt.DrivenMFT,
                        mt.UserId
                    }, commandType: CommandType.StoredProcedure)));
                }
                catch (SqlException sqlException)
                {
                    if (sqlException.Number == 2601 || sqlException.Number == 2627)
                    {
                        throw new CustomException("Duplicate", "Manufacture Code already Exists.", "Error", true, sqlException);
                    }
                    else
                    {
                        throw new CustomException("Due to some Technical Reason, Unable to Save or Update", "Error", true, sqlException);
                    }
                }
                catch (Exception ex)
                {
                    throw new CustomException("Unable to Save Or Update, Please Contact Support!!!", "Error", true, ex);
                }
            }
        }
 private void CalcSum()
 {
     if (comboBoxProduct.SelectedValue != null &&
         !string.IsNullOrEmpty(textBoxCount.Text))
     {
         try
         {
             int id = Convert.ToInt32(comboBoxProduct.SelectedValue);
             ManufactureViewModel product = _logicP.Read(new ManufactureBindingModel
             {
                 Id
                     = id
             })?[0];
             int count = Convert.ToInt32(textBoxCount.Text);
             textBoxSum.Text = (count * product?.Price ?? 0).ToString();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                             MessageBoxIcon.Error);
         }
     }
 }