Esempio n. 1
0
        public ActionResult FinishDate(Warranty record)
        {
            var           result  = false;
            var           message = "Lưu thông tin không thành công";
            WarrantyModel model   = null;

            if (AccountInfo.Type != LoginType.Sale && AccountInfo.Username != "admin")
            {
                message = "Bạn chưa có quyền sử dụng chức năng này";
            }
            else if (result = record.SaveFinishDate(UserID, Employee.ID))
            {
                message = "Lưu thông tin thành công";
                model   = Warranty.Get(UserID, Employee.ID, record.ID);
                var login = Login.Get(UserID);
                model.ViewInternalNote = login.Type == LoginType.Mechanic || login.Type == LoginType.Office || login.Username == "admin";
            }
            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    result = result,
                    message = message,
                    html = result ? RenderPartialViewToString(Views.Detail, model) : null
                }, JsonRequestBehavior.DenyGet));
            }
            var list = new WarrantyList();

            list.Current = model;
            return(View(Views.History, list));
        }
Esempio n. 2
0
        public ActionResult OldOrder(Warranty record)
        {
            if (String.IsNullOrEmpty(record.OrderCode))
            {
                record.Messages = new List <string>()
                {
                    "Chưa có mã hóa đơn"
                }
            }
            ;
            var model = new WarrantyModel();

            model.SelectedProduct = ProductInfo.Get(UserID, Employee.ID, record.ProductID, false, DbAction.Warranty.Create);
            model.Record          = record;
            var login = Login.Get(UserID);

            model.Editable = login.Type == LoginType.Office || login.Username == "admin";
            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString("SelectedProduct", model)
                }, JsonRequestBehavior.DenyGet));
            }
            return(View(Views.Save, model));
        }
        public IActionResult Create(int id = 0)
        {
            var model = new WarrantyModel();

            if (id > 0)
            {
                var warrantyData = db.CT_WarrantyTimes.Where(x => x.ID == id).FirstOrDefault();
                model = _mapper.Map(warrantyData, model);
            }
            return(View(model));
        }
Esempio n. 4
0
 public async Task <ActionResult> UpdateWarranty(OutModels.Models.Warranty warranty)
 {
     try
     {
         WarrantyModel wm = (WarrantyModel)_mapper.Map <OutModels.Models.Warranty, WarrantyModel>(warranty);
         return(new JsonResult(await this._repository.Update(wm)));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Esempio n. 5
0
        public ActionResult Create()
        {
            var model = new WarrantyModel();

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString(Views.SavePartial, model)
                }, JsonRequestBehavior.AllowGet));
            }
            return(View(Views.Save, model));
        }
Esempio n. 6
0
        public ActionResult OldOrder(int id)
        {
            var model = new WarrantyModel();

            model.SelectedProduct = ProductInfo.Get(UserID, Employee.ID, id, false, DbAction.Warranty.Create);
            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString("OldOrder", model)
                }, JsonRequestBehavior.AllowGet));
            }
            return(View(Views.Save, model));
        }
Esempio n. 7
0
        public ActionResult OrderList(ImexFilter filter)
        {
            var list = Export.OrderHistory(UserID, Employee.ID, Employee.BussinessID, filter, false, DbAction.Warranty.Create);

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    result = true,
                    html = RenderPartialViewToString("Orders", list)
                }, JsonRequestBehavior.DenyGet));
            }
            var model = new WarrantyModel(list);

            return(View(Views.Save, model));
        }
Esempio n. 8
0
        public ActionResult SelectOrder(int id)
        {
            var order = Export.GetOrder(UserID, Employee.ID, id, false, DbAction.Warranty.Create);

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString("SelectedOrder", order)
                }, JsonRequestBehavior.AllowGet));
            }
            var model = new WarrantyModel();

            model.SelectedOrder = order;
            return(View(Views.Save, model));
        }
Esempio n. 9
0
        public ActionResult ProductList(ProductFilter filter)
        {
            var list = ProductInfo.FindList(UserID, Employee.ID, Employee.BussinessID, filter, false, 100, DbAction.Warranty.Create);

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    result = true,
                    html = RenderPartialViewToString("Products", list)
                }, JsonRequestBehavior.DenyGet));
            }
            var model = new WarrantyModel(list);

            return(View(Views.Save, model));
        }
Esempio n. 10
0
        public async Task <string> AddWarrantyProxyService([FromBody] WarrantyModel model)
        {
            if (ModelState.IsValid)
            {
                var headers        = new Dictionary <string, string>();
                var tokenGenerated = HttpContext.Session.GetHmacToken();
                headers.Add("X-Hmac", tokenGenerated);
                headers.Add("X-PublicKey", HttpContext.Session.GetUserPublicKey());
                string queryStr = _queryCreater.GetQueryStringFromObject(model);
                var    response = await HttpClientRequestFactory.Get("http://proxy.mansis.co.za:18443/SlimProxyBoot.php?" + queryStr, headers);

                var data = response.Content.ReadAsStringAsync().Result;
                return(data.ToString());
            }
            else
            {
                throw new Exception("Model state is not valid");
            }
        }
        public IActionResult Create(WarrantyModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (model.ID == 0)
                    {
                        #region For Create

                        var warranty = _mapper.Map <CT_WarrantyTime>(model);
                        db.CT_WarrantyTimes.Add(warranty);
                        db.SaveChanges();

                        #endregion For Create
                        TempData["StatusMessage"] = "Successfully created";
                    }
                    else
                    {
                        #region for edit

                        var warrantyEdit = _mapper.Map <CT_WarrantyTime>(model);

                        db.Update(warrantyEdit);
                        db.SaveChanges();

                        #endregion for edit
                        TempData["StatusMessage"] = "Successfully updated";
                    }

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                TempData["StatusMessage"] = ex.Message;

                return(View(model));
            }
            return(View(model));
        }
Esempio n. 12
0
        public ActionResult Submit(Warranty record)
        {
            var result     = false;
            var list       = new WarrantyList();
            var model      = new WarrantyModel();
            var action     = record.ID > 0 ? DbAction.Warranty.Modify : DbAction.Warranty.Create;
            var warehouses = WarehouseInfo.FindAuthorized(UserID, Employee.ID, Employee.BussinessID, UserID, action);

            record.ReceiveWarehouseID = warehouses.FirstOrDefault().ID;
            model.Record = record.Save(ModelState, UserID, Employee.ID, Employee.BussinessID, Employee.Name);
            if (result = model.Record != null)
            {
                model.SelectedProduct = ProductInfo.Get(UserID, Employee.ID, record.ProductID, false, action);
                if (model.Record.OrderID.HasValue)
                {
                    model.SelectedOrder = Export.GetOrder(UserID, Employee.ID, model.Record.OrderID.Value, false, action);
                }
                var login = Login.Get(UserID);
                model.ViewInternalNote = login.Type == LoginType.Mechanic || login.Type == LoginType.Office || login.Username == "admin";
            }
            else
            {
                model.Record = record;
            }
            list.Current = model;
            var message = result ? "Lưu thông tin không thành công" : null;

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    result = result,
                    message = message,
                    html = result ? RenderPartialViewToString(Views.HistoryPartial, list) : null
                }, JsonRequestBehavior.DenyGet));
            }
            return(RedirectToAction("History"));
        }
Esempio n. 13
0
        public ActionResult SelectProduct(int id)
        {
            var model   = new WarrantyModel();
            var product = Export.GetProduct(UserID, Employee.ID, id);

            model.SelectedProduct = ProductInfo.Get(UserID, Employee.ID, product.ProductID, false, DbAction.Warranty.Create);
            if (product != null)
            {
                model.Record.ProductID = product.ProductID;
                model.SelectedOrder    = Export.GetOrder(UserID, Employee.ID, product.OrderID.Value, false, DbAction.Warranty.Create);
                if (model.SelectedOrder != null)
                {
                    model.Record.WarehouseID   = model.SelectedOrder.WarehouseID;
                    model.Record.WarehouseName = model.SelectedOrder.WarehouseName;
                    model.Record.EmployeeName  = Employee.Name;
                    model.Record.ClientID      = model.SelectedOrder.ClientID;
                    model.Record.ClientName    = model.SelectedOrder.ClientName;
                    model.Record.ClientCode    = model.SelectedOrder.ClientCode;
                    model.Record.ClientPhone   = model.SelectedOrder.ClientPhone;
                    model.Record.ClientAddress = model.SelectedOrder.ClientAddress;
                    model.Record.OrderID       = model.SelectedOrder.ID;
                    model.Record.OrderCode     = model.SelectedOrder.Code;
                }
            }
            var login = Login.Get(UserID);

            model.Editable = login.Type == LoginType.Office || login.Username == "admin";
            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString("SelectedProduct", model)
                }, JsonRequestBehavior.AllowGet));
            }
            return(View(Views.Save, model));
        }