// Actions

        /// <summary>
        /// Select items
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult SelectTmcItem(TmcViewModel model)
        {
            ApplicationPoaRepository poaRepo = new ApplicationPoaRepository(false);
            //if (model.IsSelected)
            //{
            //    poaRepo.AddLimsTmcTemp(new LimsTmcTemp()
            //    {
            //        TmcId = model.Id.Value,
            //        TmcInId = model.TmcInId.Value,
            //        CreatedDate = DateTime.Now
            //    });
            //}
            //else
            //{
            //    poaRepo.DeleteLimsTmcTemp(new LimsTmcTemp()
            //    {
            //        TmcId = model.Id.Value,
            //        TmcInId = model.TmcInId.Value
            //    });
            //}
            var limsTmcTemp = poaRepo.GetLimsTmcTemps(ltt => ltt.TmcId == model.Id.Value && ltt.TmcInId == model.TmcInId.Value)
                              .FirstOrDefault();

            if (limsTmcTemp != null)
            {
                limsTmcTemp.IsSelected = model.IsSelected;
                poaRepo.UpdateLimsTmcTemp(limsTmcTemp);
                poaRepo.Save();
            }

            return(Json(new { IsSuccess = true }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult CreateTmc([DataSourceRequest] DataSourceRequest request, TmcViewModel model)
        {
            TmcRepository repo = new TmcRepository(false);

            Tmc tmc = new Tmc()
            {
                Id                      = Guid.NewGuid(),
                StateType               = model.StateType,
                Name                    = model.Name,
                Code                    = model.Code,
                CreatedDate             = DateTime.Now,
                CreatedEmployeeId       = UserHelper.GetCurrentEmployee().Id,
                Count                   = model.Count,
                CountActual             = model.CountActual,
                OwnerEmployeeId         = model.OwnerEmployeeId,
                Number                  = model.Number,
                CountFact               = model.CountFact,
                CountConvert            = model.CountFact,
                ExpiryDate              = model.ExpiryDate,
                ManufactureDate         = model.ManufactureDate,
                Manufacturer            = model.Manufacturer,
                MeasureTypeConvertDicId = model.MeasureTypeConvertDicId,
                MeasureTypeDicId        = model.MeasureTypeDicId,
                PackageDicId            = model.PackageDicId,
                Rack                    = model.Rack,
                Safe                    = model.Safe,
                Serial                  = model.Serial,
                StorageDicId            = model.StorageDicId,
                TmcTypeDicId            = model.TmcTypeDicId,
                ReceivingDate           = model.ReceivingDate,
                TmcInId                 = Guid.Parse(model.TmcInIdString),
            };

            repo.Insert(tmc);
            repo.Save();
            model.Id = tmc.Id;

            var newDictionary = repo.TvGetAsQuarable(o => o.Id == tmc.Id).First();

            model.MeasureTypeDicValue = newDictionary.MeasureTypeDicValue;

            var appRepo = new ApplicationPoaRepository(false);

            appRepo.AddLimsTmcTemp(new LimsTmcTemp()
            {
                TmcId         = tmc.Id,
                TmcInId       = tmc.TmcInId,
                CountRequest  = model.CountRequest,
                CountReceived = null,
                IsSelected    = model.IsSelected,
                CreatedDate   = DateTime.Now
            });
            appRepo.Save();

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult UpdateTmc([DataSourceRequest] DataSourceRequest request, TmcViewModel model)
        {
            TmcRepository repo = new TmcRepository(false);
            Tmc           tmc  = repo.GetAsQuarable(o => o.Id == model.Id).FirstOrDefault();

            if (tmc != null)
            {
                //tmc.StateType = model.StateType;
                //tmc.Name = model.Name;
                //tmc.Code = model.Code;
                //tmc.Count = model.Count;
                //tmc.CountActual = model.CountRequest.Value;
                //tmc.OwnerEmployeeId = model.OwnerEmployeeId;
                //tmc.Number = model.Number;
                //tmc.CountFact = model.CountRequest.Value;
                //tmc.CountConvert = model.CountRequest.Value;
                //tmc.ExpiryDate = model.ExpiryDate;
                //tmc.ManufactureDate = model.ManufactureDate;
                //tmc.Manufacturer = model.Manufacturer;
                //tmc.MeasureTypeConvertDicId = model.MeasureTypeConvertDicId;
                //tmc.MeasureTypeDicId = model.MeasureTypeDicId;
                //tmc.PackageDicId = model.PackageDicId;
                //tmc.Rack = model.Rack;
                //tmc.Safe = model.Safe;
                //tmc.Serial = model.Serial;
                //tmc.StorageDicId = model.StorageDicId;
                //tmc.TmcTypeDicId = model.TmcTypeDicId;
                //tmc.ReceivingDate = model.ReceivingDate;
                tmc.MeasureTypeDicId = model.MeasureTypeDicId;
            }

            repo.Save();

            if (tmc != null)
            {
                var newDictionary = repo.TvGetAsQuarable(o => o.Id == tmc.Id).First();
                model.MeasureTypeDicValue = newDictionary.MeasureTypeDicValue;

                var appRepo     = new ApplicationPoaRepository(false);
                var limsTmcTemp = appRepo.GetLimsTmcTemps(ltt => ltt.TmcId == tmc.Id && ltt.TmcInId == tmc.TmcInId).FirstOrDefault();
                if (limsTmcTemp != null)
                {
                    limsTmcTemp.CountRequest  = model.CountRequest;
                    limsTmcTemp.CountReceived = model.CounReceived;
                }
                appRepo.Save();
            }
            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
Beispiel #4
0
        public ActionResult CreateRequestTakeChildrens([DataSourceRequest] DataSourceRequest request, TmcViewModel dictionary)
        {
            Tmc tmc = new Tmc()
            {
                Id                      = Guid.NewGuid(),
                StateType               = dictionary.StateType,
                Name                    = dictionary.Name,
                Code                    = dictionary.Code,
                CreatedDate             = DateTime.Now,
                CreatedEmployeeId       = UserHelper.GetCurrentEmployee().Id,
                Count                   = dictionary.Count,
                CountActual             = dictionary.CountActual,
                OwnerEmployeeId         = dictionary.OwnerEmployeeId,
                Number                  = dictionary.Number,
                CountFact               = dictionary.CountFact,
                CountConvert            = dictionary.CountFact,
                ExpiryDate              = dictionary.ExpiryDate,
                ManufactureDate         = dictionary.ManufactureDate,
                Manufacturer            = dictionary.Manufacturer,
                MeasureTypeConvertDicId = dictionary.MeasureTypeConvertDicId,
                MeasureTypeDicId        = dictionary.MeasureTypeDicId,
                PackageDicId            = dictionary.PackageDicId,
                Rack                    = dictionary.Rack,
                Safe                    = dictionary.Safe,
                Serial                  = dictionary.Serial,
                StorageDicId            = dictionary.StorageDicId,
                TmcTypeDicId            = dictionary.TmcTypeDicId,
                ReceivingDate           = dictionary.ReceivingDate,
                TmcInId                 = Guid.Parse(dictionary.TmcInIdString),
            };

            db.Tmcs.Add(tmc);
            db.SaveChanges();
            dictionary.Id = tmc.Id;

            var newDictionary = db.TmcViews.First(o => o.Id == tmc.Id);

            dictionary.MeasureTypeDicValue = newDictionary.MeasureTypeDicValue;

            return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult DestroyTmc([DataSourceRequest] DataSourceRequest request, TmcViewModel dictionary)
        {
            TmcRepository            repo    = new TmcRepository(false);
            ApplicationPoaRepository poaRepo = new ApplicationPoaRepository(false);

            if (dictionary != null)
            {
                var limsTmcTemp = poaRepo.GetLimsTmcTemps(ltt => ltt.TmcId == dictionary.Id && ltt.TmcInId == dictionary.TmcInId).FirstOrDefault();
                poaRepo.DeleteLimsTmcTemp(limsTmcTemp);
                poaRepo.Save();

                Tmc d = repo.GetAsQuarable(o => o.Id == dictionary.Id).First();
                repo.Delete(d);
                repo.Save();
            }

            return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
        }