예제 #1
0
        public bool Create(Image input)
        {
            string img = input.ImageContent;

            if (img != "")
            {
                byte[] contents = Convert.FromBase64String(img);
                //string subpath = "~/images/users";
                //bool exists = Directory.Exists(HttpContext.Current.Server.MapPath(subpath));
                //if (!exists)
                //{
                //    Directory.CreateDirectory(HttpContext.Current.Server.MapPath(subpath));
                //}
                string fileName = input.create_by + DateTime.Now.ToString("yyyyMMdd-HHMMss") + ".png";
                var    path     = Path.Combine(HttpRuntime.AppDomainAppPath + "/data/images", Path.GetFileName(fileName));

                File.WriteAllBytes(path, contents);

                input.ImageContent = path;
                _imageRepository.Insert(input);

                lichSuServices.Create(new LichSu
                {
                    HanhDong     = Constant.CreateAction,
                    TenTaiKhoan  = HttpContext.Current.User.Identity.Name,
                    NoiDung      = Constant.CvtToString(input),
                    ViTriThaoTac = Constant.No
                });
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        public void Create(NhanVienCreate input)
        {
            if (userServices.GetAll().Any(p => p.TenTaiKhoan == input.TenTaiKhoan))
            {
                input.TrangThai = 1; //default

                _repositoryNhanVien.Insert(new NhanViens {
                    TenTaiKhoan = input.TenTaiKhoan,
                    TenNhanVien = input.TenNhanVien,
                    ChucVu      = input.ChucVu,
                    DiaChi      = input.DiaChi,
                    Email       = input.Email,
                    NgaySinh    = input.NgaySinh,
                    NgayBatDau  = input.NgayBatDau,
                    SoDienThoai = input.SoDienThoai,
                    TrangThai   = input.TrangThai
                });
                lichSuServices.Create(new LichSu
                {
                    HanhDong     = Constant.CreateAction,
                    TenTaiKhoan  = userServices.GetCurrentUser().UserName,
                    NoiDung      = Constant.CvtToString(input),
                    ViTriThaoTac = Constant.NhanVien
                });
            }
            else
            {
                //throw Response
            }
        }
예제 #3
0
        public void Update(TaiKhoanUpdate input)
        {
            var curren_user = GetById(input.Id);

            if (!string.IsNullOrEmpty(input.DiaChi))
            {
                curren_user.DiaChi = input.DiaChi;
            }
            if (!string.IsNullOrEmpty(input.HoTen))
            {
                curren_user.HoTen = input.HoTen;
            }
            if (!string.IsNullOrEmpty(input.PhoneNumber))
            {
                curren_user.PhoneNumber = input.PhoneNumber;
            }
            //user.NgaySinh = input.NgaySinh; user chua co thuoc tinh NgaySinh
            UserManager.Update(curren_user);

            lichSuServices.Create(new LichSu
            {
                TenTaiKhoan  = GetCurrentUser().UserName,
                HanhDong     = Constant.UpdateAction,
                ViTriThaoTac = Constant.User,
                NoiDung      = input.Id
            });
        }
예제 #4
0
        public void Create(IdentityRole input)
        {
            _roleRepository.InsertRole(input);

            lichSuServices.Create(new LichSu {
                HanhDong     = Constant.CreateAction,
                TenTaiKhoan  = HttpContext.Current.User.Identity.Name,
                NoiDung      = Constant.CvtToString(input),
                ViTriThaoTac = Constant.Role
            });
        }
예제 #5
0
 public void Create(BangGia input)
 {
     _banggiarepository.Insert(input);
     lichSuServices.Create(new LichSu
     {
         HanhDong     = Constant.CreateAction,
         TenTaiKhoan  = HttpContext.Current.User.Identity.Name,
         NoiDung      = Constant.CvtToString(input),
         ViTriThaoTac = Constant.BangGia
     });
 }
예제 #6
0
        public void Create(HoaDon input)
        {
            _hoadonrepository.Insert(input);

            lichSuServices.Create(new LichSu
            {
                HanhDong     = Constant.CreateAction,
                TenTaiKhoan  = userServices.GetCurrentUser().UserName,
                NoiDung      = new JavaScriptSerializer().Serialize(input),
                ViTriThaoTac = "HoaDon"
            });
        }
예제 #7
0
 public void Create(No input)
 {
     input.ThoiGian = DateTime.Now;
     _noRepository.Insert(input);
     lichSuServices.Create(new LichSu
     {
         HanhDong     = Constant.CreateAction,
         TenTaiKhoan  = HttpContext.Current.User.Identity.Name,
         NoiDung      = Constant.CvtToString(input),
         ViTriThaoTac = Constant.No
     });
 }
예제 #8
0
        public void Create(UuDai input)
        {
            _uudaiRepository.Insert(input);

            lichSuServices.Create(new LichSu
            {
                TenTaiKhoan  = userServices.GetCurrentUser().UserName,
                HanhDong     = Constant.CreateAction,
                ViTriThaoTac = Constant.User,
                NoiDung      = Constant.CvtToString(input)
            });
        }
예제 #9
0
        public void Create(KhachHang input)
        {
            input.TrangThai = 1;
            _khachhangrepository.Insert(input);

            lichSuServices.Create(new LichSu
            {
                TenTaiKhoan  = HttpContext.Current.User.Identity.Name,
                HanhDong     = Constant.CreateAction,
                ViTriThaoTac = Constant.KhachHang,
                NoiDung      = Constant.CvtToString(input)
            });
        }
예제 #10
0
        public int Create(DonHang input)
        {
            DateTime time = new DateTime();

            time = DateTime.Now;
            input.ThoiDiemDatDonHang = time;
            input.TinhTrang          = 0;
            input.MaNhanVienGiao     = 0;     //Dèault
            input.deleted            = false; //Dèault
            if (input.ThanhTien == null)
            {
                input.ThanhTien = 0;
            }
            if (input.cod == null)
            {
                input.cod = 0;
            }
            if (input.MaHanhTrinh == null)
            {
                input.MaHanhTrinh = 0;
            }

            input.TenTaiKhoan = userServices.GetCurrentUser().TenTaiKhoan == null?userServices.GetCurrentUser().UserName : userServices.GetCurrentUser().TenTaiKhoan;

            _donhangRepository.Insert(input);
            DonHang input2 = new DonHang();

            input2 = _donhangRepository.GetAll().Where(p => p.ThoiDiemDatDonHang == time &&
                                                       p.TenTaiKhoan == userServices.GetCurrentUser().TenTaiKhoan &&
                                                       p.ThanhTien == input.ThanhTien && p.NguoiGui == input.NguoiGui && p.NguoiNhan == input.NguoiNhan).FirstOrDefault();
            lichSuServices.Create(new LichSu
            {
                TenTaiKhoan  = userServices.GetCurrentUser().UserName,
                HanhDong     = Constant.CreateAction,
                ViTriThaoTac = "User",
                NoiDung      = new JavaScriptSerializer().Serialize(input)
            });
            return(input2.MaDonHang);
        }