Пример #1
0
        public ActionResult Edit(int MstPenaltyId)
        {
            if (CurrentUser.UserRole == Enums.UserRole.Viewer)
            {
                return(RedirectToAction("Index"));
            }
            var data  = _penaltyBLL.GetByID(MstPenaltyId);
            var model = new PenaltyItem();

            model              = Mapper.Map <PenaltyItem>(data);
            model.VendorName   = _vendorBLL.GetByID(model.Vendor) == null ? "" : _vendorBLL.GetByID(model.Vendor).VendorName;
            model.PenaltyLogic = this.GetPenaltyLogicById(MstPenaltyId).Data.ToString();
            model              = listdata(model);
            model.MainMenu     = _mainMenu;
            model.CurrentLogin = CurrentUser;
            model.ChangesLogs  = GetChangesHistory((int)Enums.MenuList.MasterPenalty, MstPenaltyId);
            if (CurrentUser.UserRole == Enums.UserRole.Viewer)
            {
                model.IsNotViewer = false;
            }
            else
            {
                model.IsNotViewer = true;
            }
            return(View(model));
        }
Пример #2
0
        public ActionResult Create()
        {
            if (CurrentUser.UserRole == Enums.UserRole.Viewer)
            {
                return(RedirectToAction("Index"));
            }
            var model = new PenaltyItem();

            model.MainMenu     = _mainMenu;
            model.CurrentLogin = CurrentUser;
            model = listdata(model);
            return(View(model));
        }
Пример #3
0
        public ActionResult View(int MstPenaltyId)
        {
            var data  = _penaltyBLL.GetByID(MstPenaltyId);
            var model = new PenaltyItem();

            model              = Mapper.Map <PenaltyItem>(data);
            model.VendorName   = _vendorBLL.GetByID(model.Vendor) == null ? "" : _vendorBLL.GetByID(model.Vendor).VendorName;
            model.PenaltyLogic = this.GetPenaltyLogicById(MstPenaltyId).Data.ToString();
            model              = listdata(model);
            model.MainMenu     = _mainMenu;
            model.CurrentLogin = CurrentUser;
            model.ChangesLogs  = GetChangesHistory((int)Enums.MenuList.MasterPenalty, MstPenaltyId);
            return(View(model));
        }
Пример #4
0
        public ActionResult Create(PenaltyItem model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var Exist = _penaltyBLL.GetPenalty().Where(x => (x.BodyType == null ? "" : x.BodyType.ToUpper()) == (model.BodyType == null ? "" : model.BodyType.ToUpper()) &&
                                                               (x.Manufacturer == null ? "" : x.Manufacturer.ToUpper()) == (model.Manufacturer == null? "" : model.Manufacturer.ToUpper()) &&
                                                               (x.Model == null ? "" : x.Model.ToUpper()) == (model.Models == null ? "" : model.Models.ToUpper()) &&
                                                               (x.VehicleType == null ? "" :x.VehicleType.ToUpper()) == (model.VehicleType == null ? "" : model.VehicleType.ToUpper()) &&
                                                               (x.BodyType == null ? "" :x.BodyType.ToUpper()) == (model.BodyType == null ? "" : model.BodyType.ToUpper()) &&
                                                               (x.Series == null ? "" : x.Series.ToUpper()) == (model.Series == null ? "" : model.Series.ToUpper()) &&
                                                               x.Year == model.Year && x.Vendor == model.Vendor && x.Penalty == model.Penalty && x.MonthEnd == model.MonthEnd && x.MonthStart == model.MonthStart && x.IsActive).FirstOrDefault();

                    if (Exist != null)
                    {
                        model.ErrorMessage = "Data Already Exist in Master Penalty";
                        model.MainMenu     = _mainMenu;
                        model.CurrentLogin = CurrentUser;
                        model.PenaltyLogic = this.GetPenaltyLogicById(model.Penalty).Data.ToString();
                        model = listdata(model);
                        return(View(model));
                    }

                    var data = Mapper.Map <PenaltyDto>(model);
                    data.CreatedBy    = CurrentUser.USER_ID;
                    data.CreatedDate  = DateTime.Now;
                    data.ModifiedDate = null;
                    data.IsActive     = true;

                    _penaltyBLL.Save(data);
                    _penaltyBLL.SaveChanges();
                }
                catch (Exception exp)
                {
                    model.ErrorMessage = exp.Message;
                    model.MainMenu     = _mainMenu;
                    model.CurrentLogin = CurrentUser;
                    model = listdata(model);
                    return(View(model));
                }
            }
            return(RedirectToAction("Index", "MstPenalty"));
        }
Пример #5
0
        public PenaltyItem listdata(PenaltyItem model)
        {
            var Vehiclelist = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "BENEFIT", Value = "BENEFIT"
                },
                new SelectListItem {
                    Text = "WTC", Value = "WTC"
                }
            };

            model.VehicleList = new SelectList(Vehiclelist, "Value", "Text");

            var PenaltyLogicDataList = _penaltyLogicBLL.GetPenaltyLogic().Where(x => x.IsActive).Select(x => new { x.MstPenaltyLogicId }).Distinct().ToList();

            model.PenaltyList = new SelectList(PenaltyLogicDataList, "MstPenaltyLogicId", "MstPenaltyLogicId");

            var VendorDataList = _vendorBLL.GetVendor().Where(x => x.IsActive).Select(x => new { x.VendorName, x.MstVendorId }).Distinct().ToList();

            model.VendorList = new SelectList(VendorDataList, "MstVendorId", "VendorName");
            return(model);
        }
Пример #6
0
        public JsonResult UploadFile(HttpPostedFileBase upload)
        {
            var data  = (new ExcelReader()).ReadExcel(upload);
            var model = new List <PenaltyItem>();

            if (data != null)
            {
                foreach (var dataRow in data.DataRows)
                {
                    if (dataRow.Count <= 0)
                    {
                        continue;
                    }
                    if (dataRow[0] == "")
                    {
                        continue;
                    }
                    var item = new PenaltyItem();
                    item.ErrorMessage = "";

                    var vendorName = dataRow[0].ToString();
                    if (vendorName == "")
                    {
                        item.ErrorMessage = "Vendor Name Can't be Empty";
                    }
                    else
                    {
                        item.VendorName = vendorName;
                        var vendor = _vendorBLL.GetVendor().Where(x => x.IsActive && (x.VendorName == null ? "" : x.VendorName.ToUpper()) == (vendorName == null ? "" : vendorName.ToUpper())).FirstOrDefault();
                        if (vendor == null)
                        {
                            item.ErrorMessage = "Vendor is not in the Master Vendor";
                        }
                        else
                        {
                            item.Vendor = vendor.MstVendorId;
                        }
                    }

                    if (dataRow[1] == "")
                    {
                        item.ErrorMessage = "Request Year Can't be Empty";
                    }
                    else
                    {
                        try
                        {
                            item.Year = Convert.ToInt32(dataRow[1].ToString());
                        }
                        catch (Exception)
                        {
                            item.ErrorMessage = "Request year must be number";
                        }
                    }

                    if (dataRow[2] == "")
                    {
                        item.ErrorMessage = "Minimum lease Term Can't be Empty";
                    }
                    else
                    {
                        try
                        {
                            item.MonthStart = Convert.ToInt32(dataRow[2].ToString());
                        }
                        catch (Exception)
                        {
                            item.ErrorMessage = "Minimum lease Term must be number";
                        }
                    }

                    if (dataRow[3] == "")
                    {
                        item.ErrorMessage = "Maximum lease Term Can't be Empty";
                    }
                    else
                    {
                        try
                        {
                            item.MonthEnd = Convert.ToInt32(dataRow[3].ToString());
                        }
                        catch (Exception)
                        {
                            item.ErrorMessage = "Maximum lease must be number";
                        }
                    }

                    item.Manufacturer = dataRow[4].ToString();
                    item.Models       = dataRow[5].ToString();
                    item.Series       = dataRow[6].ToString();
                    item.BodyType     = dataRow[7].ToString();

                    item.VehicleType = (dataRow[8] == null ?"" :dataRow[8].ToUpper());
                    if (item.VehicleType == "")
                    {
                        item.ErrorMessage = "Vehicle Type can't be empty";
                    }

                    if (dataRow[9] == "")
                    {
                        item.ErrorMessage = "Penalty Id Can't be empty";
                    }
                    else
                    {
                        try
                        {
                            item.Penalty = Convert.ToInt32(dataRow[9].ToString());
                            var PenaltyLogic = _penaltyLogicBLL.GetPenaltyLogicById(item.Penalty);
                            if (PenaltyLogic == null)
                            {
                                item.ErrorMessage = "This Penalty Id is not in master penalty Logic";
                            }
                        }
                        catch (Exception)
                        {
                            item.ErrorMessage = "Penalty Id must be number";
                        }
                    }
                    model.Add(item);
                }
            }
            return(Json(model));
        }