Example #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            MasterUnit masterUnit = db.masterUnits.Find(id);

            db.masterUnits.Remove(masterUnit);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
        //cat.isActive = false;
        //        if (cvm.statusex == "Yes")
        //        {
        //            cat.isActive = true;
        //        }
        // GET: MasterUnits/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MasterUnit masterUnit = db.masterUnits.Find(id);

            if (masterUnit == null)
            {
                return(HttpNotFound());
            }
            return(View(masterUnit));
        }
Example #3
0
        public ActionResult Create(MasterUnit cvm)
        {
            MasterUnit cat = new MasterUnit();

            cat.Unit     = cvm.Unit;
            cat.isActive = false;
            if (cvm.statusex == "Yes")
            {
                cat.isActive = true;
            }
            db.masterUnits.Add(cat);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #4
0
        public ActionResult Edit(MasterUnit cvm)
        {
            var cat = db.masterUnits.Where(x => x.UnitID == cvm.UnitID).FirstOrDefault();

            cat.Unit     = cvm.Unit;
            cat.isActive = false;
            if (cvm.statusex == "Yes")
            {
                cat.isActive = true;
            }



            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task <Response <int> > Handle(CreateMasterCommand request, CancellationToken cancellationToken)
        {
            if (_masterRepository.IsExistMasterAsync(request.TypeMasters, request.Key).Result)
            {
                throw new ApiException($"Master is allready exist.");
            }
            var master = _mapper.Map <Master>(request);
            await _masterRepository.AddAsync(master);

            var masterUnit = new MasterUnit
            {
                MasterId = master.Id,
                UnitCode = master.UnitCode
            };
            await _masterUnitRepository.AddAsync(masterUnit);

            return(new Response <int>(master.Id));
        }