public ActionResult LookUp()
        {
            var lookUpModel = new LookUpViewModel();

            lookUpModel.Races       = new DropDownListValues();
            lookUpModel.Genders     = new DropDownListValues();
            lookUpModel.OfficerAges = new DropDownListValues();
            lookUpModel.DriverAges  = new DropDownListValues();

            lookUpModel.Races.Values = new List <string>()
            {
                "WHITE", "BLACK", "HISPANIC", "ASIAN"
            };
            lookUpModel.Genders.Values = new List <string>()
            {
                "M", "F"
            };
            lookUpModel.OfficerAges.Values = new List <string>()
            {
                "21 - 30", "31 - 40", "40 - 50", "50 - 60", "OVER 60"
            };
            lookUpModel.DriverAges.Values = new List <string>()
            {
                "16 - 19", "20 - 25", "26 - 30", "31 - 40", "41 - 50", "51 - 60", "OVER 60"
            };

            return(View(lookUpModel));
        }
        public string DeleteLookUpCode(LookUpViewModel models, string culture)
        {
            if (models == null)
            {
                return("OK");
            }

            var Codename       = models.CodeName;
            var LookUpCodeList = context.LookUpCodes.Where(a => a.CodeName == Codename).ToList();
            var titles         = context.LookUpTitles.ToList();
            var result         = "OK";

            foreach (var code in LookUpCodeList)
            {
                result = CheckLookUpCode(code.CodeName, code.CodeId, culture);
                if (result != "OK")
                {
                    return(MsgUtils.Instance.Trls(culture, "DeleteRelatedRecord").Replace("{0}", result) + ": " + context.LookUpCodes.Where(a => a.Id == code.Id).Select(a => a.Name).FirstOrDefault());
                }

                var DeleteObj = LookUpCodeList.Where(a => a.Name == code.Name).FirstOrDefault();
                context.LookUpCodes.Attach(DeleteObj);
                context.Entry(DeleteObj).State = EntityState.Deleted;
                var DeleteTitles = titles.Where(a => a.CodeName == code.CodeName).ToList();
                RemoveRange(DeleteTitles);
            }

            return(result);
        }
Beispiel #3
0
        public JsonResult SaveLookUp(LookUpViewModel lookUpViewModel)
        {
            JsonResult result = null;

            try
            {
                if (lookUpViewModel != null)
                {
                    LookUp lookUp = MasterService.GetLookUp <LookUp>(l => l.LookUpID == lookUpViewModel.LookUpID).FirstOrDefault();
                    if (lookUp != null)
                    {
                        lookUp.ModifiedBy = USER_OBJECT.UserID;
                        lookUp.ModifiedOn = DateTimeConverter.SingaporeDateTimeConversion(DateTime.Now);
                    }
                    else
                    {
                        lookUp            = new LookUp();
                        lookUp.CreatedBy  = USER_OBJECT.UserID;
                        lookUp.CreatedOn  = DateTimeConverter.SingaporeDateTimeConversion(DateTime.Now);
                        lookUp.ModifiedOn = null;
                    }

                    lookUp.LookUpCode        = lookUpViewModel.LookUpCode;
                    lookUp.LookUpDescription = lookUpViewModel.LookUpDescription;
                    lookUp.IsActive          = lookUpViewModel.IsActive;
                    lookUp.LookUpCategory    = lookUpViewModel.LookUpCategory;
                    MasterService.Save(lookUp);

                    result = Json(new { success = true, message = C.SUCCESSFUL_SAVE_MESSAGE }, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception ex)
            {
                result = Json(new { success = true, message = ex.Message }, JsonRequestBehavior.AllowGet);
            }
            return(result);
        }
Beispiel #4
0
 public MainWindow()
 {
     InitializeComponent();
     _lookUpViewModel = new LookUpViewModel(new Transformation(null));
     base.DataContext = _lookUpViewModel;
 }