示例#1
0
        public ActionResult AddNew()
        {
            var            userId   = User.Identity.GetUserId();
            var            UserInfo = _unitOfWork.User.GetMyInfo(userId);
            SupplierCityVM Obj      = new SupplierCityVM
            {
                SupplierCityID    = _unitOfWork.SupplierCity.GetMaxSerial(UserInfo.fCompanyId),
                SupplierCountry   = _unitOfWork.SupplierCountry.GetAllSupplierCountry(UserInfo.fCompanyId),
                SupplierCountryID = 1
            };

            return(PartialView(Obj));
        }
示例#2
0
        public JsonResult SaveSupplierCity(SupplierCityVM ObjToSave)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId          = User.Identity.GetUserId();
                var UserInfo        = _unitOfWork.User.GetMyInfo(userId);
                var SupplierCityObj = new SupplierCity();
                SupplierCityObj.InsDateTime       = DateTime.Now;
                SupplierCityObj.InsUserID         = userId;
                SupplierCityObj.CompanyID         = UserInfo.fCompanyId;
                SupplierCityObj.SupplierCityID    = ObjToSave.SupplierCityID;
                SupplierCityObj.SupplierCountryID = ObjToSave.SupplierCountryID;
                if (String.IsNullOrEmpty(ObjToSave.EnglishName))
                {
                    ObjToSave.EnglishName = ObjToSave.ArabicName;
                }
                SupplierCityObj.ArabicName  = ObjToSave.ArabicName;
                SupplierCityObj.EnglishName = ObjToSave.EnglishName;

                if (!ModelState.IsValid)
                {
                    string Err    = " ";
                    var    errors = ModelState.Values.SelectMany(v => v.Errors);
                    foreach (ModelError error in errors)
                    {
                        Err = Err + error.ErrorMessage + " * ";
                    }

                    Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + Err;
                    Msg.Code = 0;
                    return(Json(Msg, JsonRequestBehavior.AllowGet));
                }
                _unitOfWork.SupplierCity.Add(SupplierCityObj);
                _unitOfWork.Complete();
                _unitOfWork.SupplierCity.GetMaxSerial(UserInfo.fCompanyId).ToString();
                Msg.Code = 1;
                Msg.Msg  = Resources.Resource.AddedSuccessfully;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString();
                Msg.Code = 0;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
        }
示例#3
0
        public JsonResult DeleteSupplierCity(SupplierCityVM ObjDelete)
        {
            MsgUnit Msg = new MsgUnit();

            try
            {
                var userId   = User.Identity.GetUserId();
                var UserInfo = _unitOfWork.User.GetMyInfo(userId);

                ObjDelete.CompanyID = UserInfo.fCompanyId;
                var SupplierCityObj = new SupplierCity();
                SupplierCityObj.CompanyID      = UserInfo.fCompanyId;
                SupplierCityObj.SupplierCityID = ObjDelete.SupplierCityID;

                if (!ModelState.IsValid)
                {
                    string Err    = " ";
                    var    errors = ModelState.Values.SelectMany(v => v.Errors);
                    foreach (ModelError error in errors)
                    {
                        Err = Err + error.ErrorMessage + " * ";
                    }

                    Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + Err;
                    Msg.Code = 0;
                    return(Json(Msg, JsonRequestBehavior.AllowGet));
                }
                _unitOfWork.SupplierCity.Delete(SupplierCityObj);
                _unitOfWork.Complete();

                Msg.Code = 1;
                Msg.Msg  = Resources.Resource.DeletedSuccessfully;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Msg.Msg  = Resources.Resource.SomthingWentWrong + " : " + ex.Message.ToString();
                Msg.Code = 0;
                return(Json(Msg, JsonRequestBehavior.AllowGet));
            }
        }
示例#4
0
        public ActionResult DeleteSupplierCity(int id)
        {
            try
            {
                if (id != 0)
                {
                    var userId = User.Identity.GetUserId();

                    var UserInfo = _unitOfWork.User.GetUserByID(userId);
                    if (UserInfo == null)
                    {
                        RedirectToAction("", "");
                    }

                    var Obj             = _unitOfWork.NativeSql.GetSupplierCityByID(UserInfo.fCompanyId, id);
                    var SupplierCityObj = new SupplierCityVM {
                    };
                    SupplierCityObj.SupplierCityID      = Obj.SupplierCityID;
                    SupplierCityObj.SupplierCountryID   = Obj.SupplierCountryID;
                    SupplierCityObj.ArabicName          = Obj.ArabicName;
                    SupplierCityObj.EnglishName         = Obj.EnglishName;
                    SupplierCityObj.SupplierCountryName = _unitOfWork.NativeSql.GetSupplierCountryName(UserInfo.fCompanyId, SupplierCityObj.SupplierCountryID);


                    return(PartialView("DeleteSupplierCity", SupplierCityObj));
                }



                return(PartialView("DeleteSupplierCity", new SupplierCity()));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message.ToString();
                return(View("Error"));
            }
        }