Пример #1
0
        public int UpdateVarient(VarientModel varientModel)
        {
            int result = 0;

            using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString))
            {
                CommonRepository commonRepository = new CommonRepository(_ConnectionString);
                con.Open();
                SqlTransaction sqltrans = con.BeginTransaction();
                var            query    = "UPDATE Varient SET VarientName =@VarientName,FoodMenuId=@FoodMenuId," +
                                          "Price = @Price, " +
                                          "IsActive = @IsActive " +
                                          "WHERE Id = @Id;";
                result = con.Execute(query, varientModel, sqltrans, 0, System.Data.CommandType.Text);

                if (result > 0)
                {
                    sqltrans.Commit();
                    string output = commonRepository.SyncTableStatus("Varient");
                }
                else
                {
                    sqltrans.Rollback();
                }
            }
            return(result);
        }
Пример #2
0
        public ActionResult Varient(VarientModel varientModel, string submitButton)
        {
            varientModel.FoodMenuList = _iDropDownService.GetFoodMenuList();

            if (!ModelState.IsValid)
            {
                string errorString = this.ValidationVarient(varientModel);
                if (!string.IsNullOrEmpty(errorString))
                {
                    ViewBag.Validate = errorString;
                    return(View(varientModel));
                }
            }

            if (varientModel.Id > 0)
            {
                var result = _iVarientService.UpdateVarient(varientModel);
                ViewBag.Result = _locService.GetLocalizedHtmlString("EditSuccss");
            }
            else
            {
                var result = _iVarientService.InsertVarient(varientModel);
                ViewBag.Result = _locService.GetLocalizedHtmlString("SaveSuccess");
            }

            return(RedirectToAction("Index", "Varient"));
        }
Пример #3
0
        public int InsertVarient(VarientModel varientModel)
        {
            CommonRepository commonRepository = new CommonRepository(_ConnectionString);
            int MaxId = commonRepository.GetMaxId("Varient");

            int result = 0;

            using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString))
            {
                con.Open();
                SqlTransaction sqltrans = con.BeginTransaction();
                var            query    = "INSERT INTO Varient (Id,VarientName,FoodMenuId," +
                                          "Price, " +
                                          "IsActive)" +
                                          "VALUES (" + MaxId + ",@VarientName,@FoodMenuId," +
                                          "@Price," +
                                          "@IsActive); SELECT CAST(SCOPE_IDENTITY() as INT);";
                result = con.Execute(query, varientModel, sqltrans, 0, System.Data.CommandType.Text);

                if (result > 0)
                {
                    sqltrans.Commit();
                    string output = commonRepository.SyncTableStatus("Varient");
                }
                else
                {
                    sqltrans.Rollback();
                }
            }

            return(result);
        }
Пример #4
0
        private string ValidationVarient(VarientModel varientModel)
        {
            string ErrorString = string.Empty;

            if (string.IsNullOrEmpty(varientModel.VarientName))
            {
                ErrorString = _locService.GetLocalizedHtmlString("ValidAddOnesName");
                return(ErrorString);
            }
            //if (string.IsNullOrEmpty(varientModel.Price.ToString()) || varientModel.Price == 0)
            //{
            //    ErrorString = _locService.GetLocalizedHtmlString("ValidPrice");
            //    return ErrorString;
            //}

            return(ErrorString);
        }
Пример #5
0
        public ActionResult Varient(int?id)
        {
            VarientModel varientModel = new VarientModel();

            if (UserRolePermissionForPage.Add == true || UserRolePermissionForPage.Edit == true)
            {
                if (id > 0)
                {
                    int varientId = Convert.ToInt32(id);
                    varientModel = _iVarientService.GetAddonesById(varientId);
                }
                varientModel.FoodMenuList = _iDropDownService.GetFoodMenuList();
                return(View(varientModel));
            }
            else
            {
                return(RedirectToAction("NotFound", "Error"));
            }
        }
Пример #6
0
 public int UpdateVarient(VarientModel VarientModel)
 {
     return(_IVarientReportsitory.UpdateVarient(VarientModel));
 }
Пример #7
0
 public int InsertVarient(VarientModel VarientModel)
 {
     return(_IVarientReportsitory.InsertVarient(VarientModel));
 }