public int InsertCardTerminal(CardTerminalModel cardTerminalModel)
        {
            int result = 0;

            using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString))
            {
                CommonRepository commonRepository = new CommonRepository(_ConnectionString);
                int MaxId = commonRepository.GetMaxId("CardTerminal");

                con.Open();
                SqlTransaction sqltrans = con.BeginTransaction();
                var            query    = "INSERT INTO CardTerminal (Id, CardTerminalName," +
                                          "OutletId, " +
                                          "IsActive)" +
                                          "VALUES (" + MaxId + ",@CardTerminalName," +
                                          "@OutletId," +
                                          "@IsActive); SELECT CAST(SCOPE_IDENTITY() as INT);";
                result = con.Execute(query, cardTerminalModel, sqltrans, 0, System.Data.CommandType.Text);

                if (result > 0)
                {
                    sqltrans.Commit();
                }
                else
                {
                    sqltrans.Rollback();
                }
            }

            return(result);
        }
        public int UpdateCardTerminal(CardTerminalModel cardTerminalModel)
        {
            int result = 0;

            using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString))
            {
                con.Open();
                SqlTransaction sqltrans = con.BeginTransaction();
                var            query    = "UPDATE CardTerminal SET CardTerminalName =@CardTerminalName," +
                                          "OutletId = @OutletId, " +
                                          "IsActive = @IsActive " +
                                          "WHERE Id = @Id;";
                result = con.Execute(query, cardTerminalModel, sqltrans, 0, System.Data.CommandType.Text);

                if (result > 0)
                {
                    sqltrans.Commit();
                }
                else
                {
                    sqltrans.Rollback();
                }
            }
            return(result);
        }
Beispiel #3
0
        public ActionResult CardTerminal(CardTerminalModel cardTerminalModel, string submitButton)
        {
            if (!ModelState.IsValid)
            {
                string errorString = this.ValidationCardTerminal(cardTerminalModel);
                if (!string.IsNullOrEmpty(errorString))
                {
                    ViewBag.Validate = errorString;
                    return(View(cardTerminalModel));
                }
            }

            if (cardTerminalModel.Id > 0)
            {
                var result = _iCardTerminalService.UpdateCardTerminal(cardTerminalModel);
                ViewBag.Result = _locService.GetLocalizedHtmlString("EditSuccss");
            }
            else
            {
                var result = _iCardTerminalService.InsertCardTerminal(cardTerminalModel);
                ViewBag.Result = _locService.GetLocalizedHtmlString("SaveSuccess");
            }
            cardTerminalModel.OutletList = _iDropDownService.GetOutletList();

            return(RedirectToAction("Index", "CardTerminal"));
        }
Beispiel #4
0
        private string ValidationCardTerminal(CardTerminalModel cardTerminalModel)
        {
            string ErrorString = string.Empty;

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

            return(ErrorString);
        }
Beispiel #5
0
        public ActionResult CardTerminal(int?id)
        {
            CardTerminalModel cardTerminalModel = new CardTerminalModel();

            if (UserRolePermissionForPage.Add == true || UserRolePermissionForPage.Edit == true)
            {
                if (id > 0)
                {
                    int cardTerminalId = Convert.ToInt32(id);
                    cardTerminalModel = _iCardTerminalService.GetCardTerminalById(cardTerminalId);
                }
                cardTerminalModel.OutletList = _iDropDownService.GetOutletList();

                return(View(cardTerminalModel));
            }
            else
            {
                return(RedirectToAction("NotFound", "Error"));
            }
        }
 public int UpdateCardTerminal(CardTerminalModel cardTerminalModel)
 {
     return(_IcardTerminalRepository.UpdateCardTerminal(cardTerminalModel));
 }
 public int InsertCardTerminal(CardTerminalModel cardTerminalModel)
 {
     return(_IcardTerminalRepository.InsertCardTerminal(cardTerminalModel));
 }