예제 #1
0
        public IActionResult SaveEmployee(Membership model)
        {
            if (Request.Form.Files.Count > 0)
            {
                var file = Request.Form.Files[0];
                if (file != null)
                {
                    string fileExtension = Path.GetExtension(file.FileName);
                    string fileName      = Path.GetFileNameWithoutExtension(file.FileName);
                    fileName = AppGlobal.SetName(fileName);
                    fileName = model.Phone + fileExtension;
                    var physicalPath = Path.Combine(_hostingEnvironment.WebRootPath, "images/Membership", fileName);
                    using (var stream = new FileStream(physicalPath, FileMode.Create))
                    {
                        file.CopyTo(stream);
                        model.Image = fileName;
                    }
                }
            }

            if (model.ID > 0)
            {
                Initialization(model, 1);
                model.Initialization(InitType.Update, RequestUserID);
                _membershipRepository.Update(model.ID, model);
            }
            else
            {
                Initialization(model, 0);
                model.Initialization(InitType.Insert, RequestUserID);
                _membershipRepository.Create(model);
            }
            return(RedirectToAction("EmployeeInfo", new { ID = model.ID }));
        }
예제 #2
0
        public IActionResult SaveChange(Product model)
        {
            if (Request.Form.Files.Count > 0)
            {
                var file = Request.Form.Files[0];
                if (file != null)
                {
                    string fileExtension = Path.GetExtension(file.FileName);
                    string fileName      = Path.GetFileNameWithoutExtension(file.FileName);
                    fileName = AppGlobal.SetName(model.Title);
                    fileName = fileName + "-" + AppGlobal.DateTimeCode + fileExtension;
                    var physicalPath = Path.Combine(_hostingEnvironment.WebRootPath, AppGlobal.URLProduct, fileName);
                    using (var stream = new FileStream(physicalPath, FileMode.Create))
                    {
                        file.CopyTo(stream);
                        model.ImageThumbnail = fileName;
                        model.Image          = AppGlobal.Domain + AppGlobal.URLProduct + "/" + model.ImageThumbnail;
                    }
                }
            }
            if (string.IsNullOrEmpty(model.MetaTitle))
            {
                model.MetaTitle = AppGlobal.SetName(model.Title);
            }
            if (model.ID > 0)
            {
                model.Initialization(InitType.Update, RequestUserID);
                _productRepository.Update(model.ID, model);
            }
            else
            {
                model.Initialization(InitType.Insert, RequestUserID);
                _productRepository.Create(model);
            }
            if (model.ID > 0)
            {
            }
            string controller = "Product";
            string action     = "Detail";

            return(RedirectToAction(action, controller, new { ID = model.ID }));
        }
예제 #3
0
        public IActionResult SaveFiles(Product model)
        {
            if (Request.Form.Files.Count > 0)
            {
                List <ProductConfig> list = new List <ProductConfig>();
                for (int i = 0; i < Request.Form.Files.Count; i++)
                {
                    var file = Request.Form.Files[i];
                    if (file != null)
                    {
                        string fileExtension = Path.GetExtension(file.FileName);
                        string fileName      = Path.GetFileNameWithoutExtension(file.FileName);

                        fileName = AppGlobal.SetName(fileName);
                        fileName = model.ID + "-" + fileName + "-" + AppGlobal.DateTimeCode + fileExtension;
                        var physicalPath = Path.Combine(_hostingEnvironment.WebRootPath, AppGlobal.URLProduct, fileName);
                        using (var stream = new FileStream(physicalPath, FileMode.Create))
                        {
                            file.CopyTo(stream);
                            ProductConfig productConfig = new ProductConfig();
                            productConfig.Initialization(InitType.Insert, RequestUserID);
                            productConfig.ParentID = model.ID;
                            productConfig.Title    = model.Title;
                            productConfig.FileName = fileName;
                            productConfig.URL      = AppGlobal.Domain + AppGlobal.URLProduct + "/" + fileName;
                            productConfig.Note     = fileExtension;
                            try
                            {
                                _productConfigRepository.Create(productConfig);
                            }
                            catch (Exception e)
                            {
                                string mes = e.Message;
                            }
                        }
                    }
                }
            }
            return(RedirectToAction("DetailFiles", "Product", new { ID = model.ID }));
        }
예제 #4
0
        public IActionResult SavePhieuYeuCau_ThuocTinh(PhieuYeuCauViewModel model)
        {
            if ((model.PhieuYeuCauDataTransfer.ID > 0) && (model.PhieuYeuCau_ThuocTinhDataTransfer != null))
            {
                PhieuYeuCau phieuYeuCau = _phieuYeuCauRepository.GetByID(model.PhieuYeuCauDataTransfer.ID);
                if (phieuYeuCau != null)
                {
                    phieuYeuCau.DangXuLy  = model.PhieuYeuCau_ThuocTinhDataTransfer.DangXuLy001;
                    phieuYeuCau.HoanThanh = model.PhieuYeuCau_ThuocTinhDataTransfer.HoanThanh001;
                    _phieuYeuCauRepository.Update(phieuYeuCau.ID, phieuYeuCau);
                    PhieuYeuCau_ThuocTinh phieuYeuCau_ThuocTinhBinhLuan = model.PhieuYeuCau_ThuocTinhDataTransfer;
                    phieuYeuCau_ThuocTinhBinhLuan.NguoiTaoID    = RequestUserID;
                    phieuYeuCau_ThuocTinhBinhLuan.NgayTao       = DateTime.Now;
                    phieuYeuCau_ThuocTinhBinhLuan.PhieuYeuCauID = model.PhieuYeuCauDataTransfer.ID;
                    phieuYeuCau_ThuocTinhBinhLuan.ParentID      = model.PhieuYeuCauDataTransfer.ID;
                    phieuYeuCau_ThuocTinhBinhLuan.Code          = AppGlobal.PhieuYeuCauPhanHoi;
                    if (phieuYeuCau_ThuocTinhBinhLuan.ID > 0)
                    {
                        phieuYeuCau_ThuocTinhBinhLuan.Initialization(InitType.Update, RequestUserID);
                        _phieuYeuCau_ThuocTinhRepository.Update(phieuYeuCau_ThuocTinhBinhLuan.ID, phieuYeuCau_ThuocTinhBinhLuan);
                    }
                    else
                    {
                        phieuYeuCau_ThuocTinhBinhLuan.Initialization(InitType.Insert, RequestUserID);
                        _phieuYeuCau_ThuocTinhRepository.Create(phieuYeuCau_ThuocTinhBinhLuan);
                    }
                    if (phieuYeuCau_ThuocTinhBinhLuan.ID > 0)
                    {
                        if (Request.Form.Files.Count > 0)
                        {
                            StringBuilder txt = new StringBuilder();
                            for (int i = 0; i < Request.Form.Files.Count; i++)
                            {
                                var file = Request.Form.Files[i];
                                if (file != null)
                                {
                                    string fileExtension = Path.GetExtension(file.FileName);
                                    string fileName      = Path.GetFileNameWithoutExtension(file.FileName);
                                    fileName = AppGlobal.SetName(model.PhieuYeuCauDataTransfer.TieuDe);
                                    fileName = phieuYeuCau_ThuocTinhBinhLuan.PhieuYeuCauID + "-" + phieuYeuCau_ThuocTinhBinhLuan.ID + "-" + fileName + "-" + AppGlobal.DateTimeCode + fileExtension;
                                    var physicalPath = Path.Combine(_hostingEnvironment.WebRootPath, AppGlobal.URLPhieuYeuCau, fileName);
                                    using (var stream = new FileStream(physicalPath, FileMode.Create))
                                    {
                                        file.CopyTo(stream);
                                        PhieuYeuCau_ThuocTinh phieuYeuCau_ThuocTinh = new PhieuYeuCau_ThuocTinh();
                                        phieuYeuCau_ThuocTinh.Initialization(InitType.Insert, RequestUserID);
                                        phieuYeuCau_ThuocTinh.Code          = AppGlobal.PhieuYeuCauDinhKem;
                                        phieuYeuCau_ThuocTinh.NguoiTaoID    = RequestUserID;
                                        phieuYeuCau_ThuocTinh.NgayTao       = DateTime.Now;
                                        phieuYeuCau_ThuocTinh.PhieuYeuCauID = phieuYeuCau_ThuocTinhBinhLuan.PhieuYeuCauID;
                                        phieuYeuCau_ThuocTinh.ParentID      = phieuYeuCau_ThuocTinhBinhLuan.ID;
                                        phieuYeuCau_ThuocTinh.Title         = fileName;
                                        _phieuYeuCau_ThuocTinhRepository.Create(phieuYeuCau_ThuocTinh);

                                        if ((fileExtension.Contains(@".png") == true) || (fileExtension.Contains(@".jpg") == true) || (fileExtension.Contains(@".gif") == true) || (fileExtension.Contains(@".ipeg") == true) || (fileExtension.Contains(@".webp") == true))
                                        {
                                            string url = "/" + AppGlobal.URLPhieuYeuCau + "/" + fileName;
                                            txt.AppendLine("<br/>");
                                            txt.AppendLine("<img src='" + url + "' class='img-thumbnail' alt='" + model.PhieuYeuCauDataTransfer.TieuDe + "' title='" + model.PhieuYeuCauDataTransfer.TieuDe + "' />");
                                        }
                                    }
                                }
                            }
                            phieuYeuCau_ThuocTinhBinhLuan.Title = phieuYeuCau_ThuocTinhBinhLuan.Title + txt.ToString();
                            _phieuYeuCau_ThuocTinhRepository.Update(phieuYeuCau_ThuocTinhBinhLuan.ID, phieuYeuCau_ThuocTinhBinhLuan);
                        }
                    }
                }
            }
            string controller = "PhieuYeuCau";
            string action     = "InfoByNhanVienID";

            if (RequestUserID > 0)
            {
                Membership membership = _membershipRepository.GetByID(RequestUserID);
                if (membership != null)
                {
                    if (membership.ParentID == AppGlobal.QuanTriID)
                    {
                        action = "Detail";
                    }
                }
            }
            return(RedirectToAction(action, controller, new { ID = model.PhieuYeuCauDataTransfer.ID }));
        }
예제 #5
0
        public IActionResult SavePhieuYeuCau(PhieuYeuCau model)
        {
            model.NgayTao = new DateTime(model.NgayTao.Value.Year, model.NgayTao.Value.Month, model.NgayTao.Value.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            if (model.ID > 0)
            {
                model.Initialization(InitType.Update, RequestUserID);
                _phieuYeuCauRepository.Update(model.ID, model);
            }
            else
            {
                model.Initialization(InitType.Insert, RequestUserID);
                _phieuYeuCauRepository.Create(model);
            }
            if (model.ID > 0)
            {
                if (Request.Form.Files.Count > 0)
                {
                    StringBuilder txt = new StringBuilder();
                    for (int i = 0; i < Request.Form.Files.Count; i++)
                    {
                        var file = Request.Form.Files[i];
                        if (file != null)
                        {
                            string fileExtension = Path.GetExtension(file.FileName);
                            string fileName      = Path.GetFileNameWithoutExtension(file.FileName);
                            fileName = AppGlobal.SetName(model.TieuDe);
                            fileName = model.ID + "-" + fileName + "-" + AppGlobal.DateTimeCode + fileExtension;
                            var physicalPath = Path.Combine(_hostingEnvironment.WebRootPath, AppGlobal.URLPhieuYeuCau, fileName);
                            using (var stream = new FileStream(physicalPath, FileMode.Create))
                            {
                                file.CopyTo(stream);
                                PhieuYeuCau_ThuocTinh phieuYeuCau_ThuocTinh = new PhieuYeuCau_ThuocTinh();
                                phieuYeuCau_ThuocTinh.Initialization(InitType.Insert, RequestUserID);
                                phieuYeuCau_ThuocTinh.Code          = AppGlobal.PhieuYeuCauDinhKem;
                                phieuYeuCau_ThuocTinh.NguoiTaoID    = RequestUserID;
                                phieuYeuCau_ThuocTinh.NgayTao       = DateTime.Now;
                                phieuYeuCau_ThuocTinh.PhieuYeuCauID = model.ID;
                                phieuYeuCau_ThuocTinh.ParentID      = model.ID;
                                phieuYeuCau_ThuocTinh.Title         = fileName;
                                phieuYeuCau_ThuocTinh.URL           = AppGlobal.DomainSub + "/" + AppGlobal.URLPhieuYeuCau + "/" + phieuYeuCau_ThuocTinh.Title;
                                _phieuYeuCau_ThuocTinhRepository.Create(phieuYeuCau_ThuocTinh);
                                if ((fileExtension.Contains(@".png") == true) || (fileExtension.Contains(@".jpg") == true) || (fileExtension.Contains(@".gif") == true) || (fileExtension.Contains(@".ipeg") == true) || (fileExtension.Contains(@".webp") == true))
                                {
                                    txt.AppendLine("<br/>");
                                    txt.AppendLine("<img src='" + phieuYeuCau_ThuocTinh.URL + "' class='img-thumbnail' alt='" + model.TieuDe + "' title='" + model.TieuDe + "' />");
                                }
                            }
                        }
                    }
                    model.NoiDung = model.NoiDung + txt.ToString();
                    _phieuYeuCauRepository.Update(model.ID, model);
                }
            }
            string controller = "PhieuYeuCau";
            string action     = "DetailByNhanVienID";

            if (RequestUserID > 0)
            {
                Membership membership = _membershipRepository.GetByID(RequestUserID);
                if (membership != null)
                {
                    if (membership.ParentID == AppGlobal.QuanTriID)
                    {
                        action = "Detail";
                    }
                }
            }
            return(RedirectToAction(action, controller, new { ID = model.ID }));
        }
        public IActionResult Save(AM_PhieuYeuCauViewModel model)
        {
            if (model.Membership != null)
            {
                model.Membership.ParentID = AppGlobal.DoanhNghiepID;
                if (model.AM_PhieuYeuCau.KhachHangID == 0)
                {
                    model.Membership.Initialization(InitType.Insert, RequestUserID);
                    _membershipResposistory.Create(model.Membership);
                    model.AM_PhieuYeuCau.KhachHangID = model.Membership.ID;
                }
                else
                {
                    model.Membership.Initialization(InitType.Update, RequestUserID);
                    _membershipResposistory.Update(model.AM_PhieuYeuCau.KhachHangID.Value, model.Membership);
                }
            }
            if (model.AM_PhieuYeuCau.KhachHangID > 0)
            {
                model.AM_PhieuYeuCau.DaGui      = true;
                model.AM_PhieuYeuCau.NgayTao    = DateTime.Now;
                model.AM_PhieuYeuCau.NguoiTaoID = RequestUserID;
                if (model.AM_PhieuYeuCau.ID > 0)
                {
                    model.AM_PhieuYeuCau.Initialization(InitType.Update, RequestUserID);
                    _aM_PhieuYeuCauResposistory.Update(model.AM_PhieuYeuCau.ID, model.AM_PhieuYeuCau);
                }
                else
                {
                    model.AM_PhieuYeuCau.Initialization(InitType.Insert, RequestUserID);
                    _aM_PhieuYeuCauResposistory.Create(model.AM_PhieuYeuCau);
                }
                if (model.AM_PhieuYeuCau.ID > 0)
                {
                    if (Request.Form.Files.Count > 0)
                    {
                        StringBuilder txt = new StringBuilder();
                        for (int i = 0; i < Request.Form.Files.Count; i++)
                        {
                            var file = Request.Form.Files[i];
                            if (file != null)
                            {
                                string fileExtension = Path.GetExtension(file.FileName);
                                string fileName      = Path.GetFileNameWithoutExtension(file.FileName);
                                fileName = AppGlobal.SetName(model.AM_PhieuYeuCau.TieuDe);
                                fileName = model.AM_PhieuYeuCau.ID + "-" + fileName + "-" + AppGlobal.DateTimeCode + fileExtension;
                                var physicalPath = Path.Combine(_hostingEnvironment.WebRootPath, AppGlobal.URLPhieuYeuCau, fileName);
                                using (var stream = new FileStream(physicalPath, FileMode.Create))
                                {
                                    file.CopyTo(stream);
                                    AM_PhieuYeuCau_ThuocTinh phieuYeuCau_ThuocTinh = new AM_PhieuYeuCau_ThuocTinh();
                                    phieuYeuCau_ThuocTinh.Initialization(InitType.Insert, RequestUserID);
                                    phieuYeuCau_ThuocTinh.Code          = AppGlobal.PhieuYeuCauDinhKem;
                                    phieuYeuCau_ThuocTinh.NguoiTaoID    = RequestUserID;
                                    phieuYeuCau_ThuocTinh.NgayTao       = DateTime.Now;
                                    phieuYeuCau_ThuocTinh.PhieuYeuCauID = model.AM_PhieuYeuCau.ID;
                                    phieuYeuCau_ThuocTinh.ParentID      = model.AM_PhieuYeuCau.ID;
                                    phieuYeuCau_ThuocTinh.Title         = fileName;
                                    phieuYeuCau_ThuocTinh.URL           = AppGlobal.DomainSub + "/" + AppGlobal.URLPhieuYeuCau + "/" + phieuYeuCau_ThuocTinh.Title;
                                    _aM_PhieuYeuCau_ThuocTinhRepository.Create(phieuYeuCau_ThuocTinh);
                                    if ((fileExtension.Contains(@".png") == true) || (fileExtension.Contains(@".jpg") == true) || (fileExtension.Contains(@".gif") == true) || (fileExtension.Contains(@".jpeg") == true) || (fileExtension.Contains(@".webp") == true))
                                    {
                                        txt.AppendLine("<br/>");
                                        txt.AppendLine("<img src='" + phieuYeuCau_ThuocTinh.URL + "' class='img-thumbnail' style='width:50%; height:50%;' alt='" + model.AM_PhieuYeuCau.TieuDe + "' title='" + model.AM_PhieuYeuCau.TieuDe + "' />");
                                    }
                                }
                            }
                        }
                        model.AM_PhieuYeuCau.NoiDung = model.AM_PhieuYeuCau.NoiDung + txt.ToString();
                        _aM_PhieuYeuCauResposistory.Update(model.AM_PhieuYeuCau.ID, model.AM_PhieuYeuCau);
                    }
                }
            }
            string controller = "AM_PhieuYeuCau";
            string action     = "Detail";

            return(RedirectToAction(action, controller, new { ID = model.AM_PhieuYeuCau.ID }));
        }