Beispiel #1
0
        // GET: Purchase/Create
        public ActionResult PurchaseFoodMenu(long?id, string type)
        {
            PurchaseModel purchaseModel = new PurchaseModel();

            if (UserRolePermissionForPage.Add == true || UserRolePermissionForPage.Edit == true || UserRolePermissionForPage.View == true)
            {
                if (id > 0)
                {
                    ViewBag.ActionType = type;
                    long purchaseId = Convert.ToInt64(id);
                    purchaseModel = _iPurchaseService.GetPurchaseFoodMenuById(purchaseId);
                }
                else
                {
                    purchaseModel.Date        = DateTime.UtcNow.AddMinutes(LoginInfo.Timeoffset);
                    purchaseModel.ReferenceNo = _iPurchaseService.ReferenceNumberFoodMenu().ToString();
                }
                purchaseModel.SupplierList = _iDropDownService.GetSupplierList();
                purchaseModel.StoreList    = _iDropDownService.GetStoreList();
                //purchaseModel.FoodMenuList = _iDropDownService.GetFoodMenuList();
                purchaseModel.EmployeeList = _iDropDownService.GetEmployeeList();
                return(View(purchaseModel));
            }
            else
            {
                return(RedirectToAction("NotFound", "Error"));
            }
        }
        public ActionResult SalesFoodMenu(SalesModel purchaseModel, string Cancel)
        {
            purchaseModel.CustomerList = _iDropDownService.GetSupplierList();
            purchaseModel.StoreList    = _iDropDownService.GetStoreList();
            purchaseModel.EmployeeList = _iDropDownService.GetEmployeeList();

            string purchaseMessage = string.Empty;

            if (!ModelState.IsValid)
            {
                string errorString = this.ValidationPurchase(purchaseModel);
                if (!string.IsNullOrEmpty(errorString))
                {
                    return(Json(new { error = true, message = errorString, status = 201 }));
                }
            }

            if (purchaseModel.SalesDetails != null)
            {
                if (purchaseModel.SalesDetails.Count > 0)
                {
                    purchaseModel.InventoryType = 1;
                    if (purchaseModel.Id > 0)
                    {
                        int result = _iSalesService.UpdatePurchaseFoodMenu(purchaseModel);
                        if (result > 0)
                        {
                            purchaseMessage = _locService.GetLocalizedHtmlString("EditSuccss");

                            //ClientModel clientModel = new ClientModel();
                            //clientModel = _iSalesService.GetClientDetail();
                            //_iEmailService.SendEmailToForFoodMenuPurchase(Convert.ToInt32(purchaseModel.Id), clientModel);
                        }
                    }
                    else
                    {
                        purchaseModel.ReferenceNo = _iSalesService.ReferenceNumberFoodMenu().ToString();

                        string result = _iSalesService.InsertPurchaseFoodMenu(purchaseModel);
                        if (result != "")
                        {
                            purchaseMessage = _locService.GetLocalizedHtmlString("SaveSuccess") + " Reference No is: " + result.ToString();

                            //ClientModel clientModel = new ClientModel();
                            //clientModel = _iSalesService.GetClientDetail();
                            //purchaseId = _iSalesService.GetPurchaseIdByReferenceNo(result);
                            //_iEmailService.SendEmailToForFoodMenuPurchase(purchaseId, clientModel);
                        }
                    }
                }
                else
                {
                    purchaseMessage = _locService.GetLocalizedHtmlString("ValidPurchaseDetails");
                    return(Json(new { error = true, message = purchaseMessage, status = 201 }));
                }
            }
            else
            {
                purchaseMessage = _locService.GetLocalizedHtmlString("ValidPurchaseDetails");
                return(Json(new { error = true, message = purchaseMessage, status = 201 }));
            }
            // return View(purchaseModel);
            return(Json(new { error = false, message = purchaseMessage, status = 200 }));
            //return View();
        }