Example #1
0
        public SingleRsp CreateCustomer(CustomerReq customer)
        {
            var res         = new SingleRsp();
            var customerNew = new Customers()
            {
                FullName  = customer.FullName,
                AccountId = customer.AccountId,
                BirthDate = customer.BirthDate,
                Address   = customer.Address,
                HomePhone = customer.HomePhone,
                Notes     = customer.Notes
            };

            res = _rep.CreateCustomer(customerNew);
            return(res);
        }
Example #2
0
        public override SingleRsp Update(Customers m)
        {
            var res = new SingleRsp();
            var m1  = m.CustomerId > 0 ? _rep.Read(m.CustomerId) : _rep.Read(m.FullName);

            if (m1 == null)
            {
                res.SetError("EZ103", "No Data.");
            }
            else
            {
                res      = base.Update(m);
                res.Data = m;
            }
            return(res);
        }
Example #3
0
        public SingleRsp DeleteChiTietDH(int id)
        {
            var res = new SingleRsp();

            try
            {
                res.Data = _rep.DeleteChiTietDH(id);
            }
            catch (Exception ex)
            {
                res.SetError(ex.StackTrace);
            }


            return(res);
        }
        /// <summary>
        /// Read single object
        /// </summary>
        /// <param name="id">Primary key</param>
        /// <returns>Return the object</returns>
        public override SingleRsp Read(string id)
        {
            var res = new SingleRsp();

            try
            {
                var m = _rep.Read(id);
                res.Data = m;
            }
            catch (Exception ex)
            {
                res.SetError(ex.StackTrace);
            }

            return(res);
        }
Example #5
0
        /// <summary>
        /// Create the model
        /// </summary>
        /// <param name="m">The model</param>
        /// <returns>Return the result</returns>
        public virtual SingleRsp Create(T m)
        {
            var res = new SingleRsp();

            try
            {
                var now = DateTime.Now;
                _rep.Create(m);
            }
            catch (Exception ex)
            {
                res.SetError(ex.StackTrace);
            }

            return(res);
        }
        //===========================================================
        //===========================================================

        #region -- Update User --

        public SingleRsp UpdateUser(int id, UsersReq u)
        {
            var res  = new SingleRsp();
            var user = All.FirstOrDefault(x => x.UserId.Equals(id));

            user.Username = u.username;
            user.Password = u.password;
            user.Email    = u.email;
            user.FullName = u.full_name;
            user.Phone    = u.phone;
            user.Address  = u.address;
            user.IsAdmin  = u.is_admin;
            user.IsActive = u.is_active;
            res           = _rep.UpdateUser(user);
            return(res);
        }
        public SingleRsp UpdateBangDiem(BangDiemReq bangdiem)
        {
            var      res = new SingleRsp();
            BangDiem bd  = new BangDiem();

            bd.MaBangDiem  = bangdiem.MaBangDiem;
            bd.MaBaiTap    = bangdiem.MaBaiTap;
            bd.TenDangNhap = bangdiem.TenDangNhap;
            bd.SoCauHoi    = bangdiem.SoCauHoi;
            bd.SoCauDung   = bangdiem.SoCauDung;
            bd.Diem        = bangdiem.Diem;
            bd.TinhTrang   = bangdiem.TinhTrang;
            bd.GhiChu      = bangdiem.GhiChu;
            res            = _rep.UpdateBangDiem(bd);

            return(res);
        }
Example #8
0
        //===========================================================
        //===========================================================
        #region -- Update User --

        public SingleRsp UpdateUser(UsersReq u)
        {
            var   res  = new SingleRsp();
            Users user = new Users();

            user.UserId   = u.UserId;
            user.Username = u.Username;
            user.Password = u.Password;
            user.Email    = u.Email;
            user.FullName = u.FullName;
            user.Phone    = u.Phone;
            user.Address  = u.Address;
            user.IsAdmin  = u.IsAdmin;
            user.IsActive = u.IsActive;
            res           = _rep.UpdateUser(user);
            return(res);
        }
        public override SingleRsp Update(CapBac m)
        {
            var res = new SingleRsp();

            var m1 = m.MaCapBac != null?_rep.Read(m.MaCapBac) : _rep.Read(m.MoTa);

            if (m1 == null)
            {
                res.SetError("EZ103", "No data.");
            }
            else
            {
                res      = base.Update(m);
                res.Data = m;
            }
            return(res);
        }
Example #10
0
        public SingleRsp UpdateProduct(SanPhamReq pro)
        {
            var res      = new SingleRsp();
            Hoa products = new Hoa();

            products.MaHoa   = pro.MaHoa;
            products.TenHoa  = pro.TenHoa;
            products.MaNcc   = pro.MaNcc;
            products.GiaMua  = pro.GiaMua;
            products.GiaBan  = pro.GiaBan;
            products.SoLuong = pro.SoLuong;
            products.TonKho  = pro.TonKho;
            products.Mota    = pro.Mota;
            res = _rep.UpdateProduct(products);

            return(res);
        }
        public SingleRsp UpdateAccount(AccountReq acc)
        {
            var res       = new SingleRsp();
            var accUpdate = new Accounts()
            {
                AccountId   = acc.AccountId,
                Email       = acc.Email,
                Password    = acc.Password,
                DisplayName = acc.DisplayName,
                AvatarURL   = acc.AvatarURL,
                Gender      = acc.Gender,
                YearOfBirth = acc.YearOfBirth
            };

            res = _rep.UpdateAccount(accUpdate);
            return(res);
        }
Example #12
0
        public override SingleRsp Update(NguoiDung m)
        {
            var res = new SingleRsp();

            var m1 = m.MaNguoiDung > 0 ? _rep.Read(m.MaNguoiDung) : _rep.Read(m.TenNguoiDung);

            if (m1 == null)
            {
                res.SetError("EZ103", "No data.");
            }
            else
            {
                res      = base.Update(m);
                res.Data = m;
            }
            return(res);
        }
Example #13
0
        public SingleRsp CreateKhachHang(KhachHangReq kh)
        {
            var       res       = new SingleRsp();
            KhachHang khachhang = new KhachHang();

            khachhang.MaKh     = kh.MaKh;
            khachhang.HoKh     = kh.HoKh;
            khachhang.TenKh    = kh.TenKh;
            khachhang.GioiTinh = kh.GioiTinh;
            khachhang.DiaChi   = kh.DiaChi;
            khachhang.Sdt      = kh.Sdt;
            khachhang.Fax      = kh.Fax;


            res = _rep.CreateKhachHang(khachhang);
            return(res);
        }
        public override SingleRsp Update(BangDiem m)
        {
            var res = new SingleRsp();

            var m1 = m.MaBangDiem > 0 ? _rep.Read(m.MaBangDiem) : _rep.Read(m.GhiChu);

            if (m1 == null)
            {
                res.SetError("EZ103", "No data.");
            }
            else
            {
                res      = base.Update(m);
                res.Data = m;
            }
            return(res);
        }
        //===========================================================
        //===========================================================

        #region -- Create Users --

        public SingleRsp CreateUser(UsersReq u)
        {
            var   res  = new SingleRsp();
            Users user = new Users();

            user.UserId   = u.id;
            user.Username = u.username;
            user.Password = u.password;
            user.Email    = u.email;
            user.FullName = u.full_name;
            user.Phone    = u.phone;
            user.Address  = u.address;
            user.IsAdmin  = u.is_admin;
            user.IsActive = u.is_active;
            res           = _rep.CreateUser(user);
            return(res);
        }
 public IActionResult SearchTS([FromBody] SearchThiSinhReq req)
 {
     try
     {
         var res  = new SingleRsp();
         var SoGD = _svc.SearchTS(req.Keyword, req.Page, req.Size);
         if (!(SoGD is null))
         {
             res.Data = SoGD;
             return(Ok(res));
         }
         return(NotFound());
     }
     catch (Exception)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data from database"));
     }
 }
Example #17
0
        //Thêm sản phẩm
        public SingleRsp CreateProduct(ProductReq productsReq)
        {
            var      res      = new SingleRsp();
            Products products = new Products();

            products.ProductId       = productsReq.ProductId;
            products.ProductName     = productsReq.ProductName;
            products.CategoryId      = productsReq.CategoryId;
            products.QuantityPerUnit = productsReq.QuantityPerUnit;
            products.UnitPrice       = productsReq.UnitPrice;
            products.UnitsInStock    = productsReq.UnitsInStock;
            products.UnitsOnOrder    = productsReq.UnitsOnOrder;
            products.ReorderLevel    = productsReq.ReorderLevel;
            products.Discontinued    = productsReq.Discontinued;
            res = _rep.CreateProduct(products);

            return(res);
        }
Example #18
0
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="m">The model</param>
        /// <returns>Return the result</returns>
        public override SingleRsp Update(Employees m)
        {
            var res = new SingleRsp();

            var m1 = m.EmployeeId > 0 ? _rep.Read(m.EmployeeId) : _rep.Read(m.LastName);

            if (m1 == null)
            {
                res.SetError("EZ103", "No data.");
            }
            else
            {
                res      = base.Update(m);
                res.Data = m;
            }

            return(res);
        }
        public override SingleRsp Update(ViewTongChi m)
        {
            var res = new SingleRsp();

            var m1 = m.MaTk > 0 ? _rep.Read(m.MaTk) : _rep.Read(m.MaTk);

            if (m1 == null)
            {
                res.SetError("EZ103", "No data.");
            }
            else
            {
                res      = base.Update(m);
                res.Data = m;
            }

            return(res);
        }
Example #20
0
        public override SingleRsp Update(TaiKhoan m)
        {
            var res = new SingleRsp();

            var m1 = m.MaTaiKhoan > 0 ? _rep.Read(m.MaTaiKhoan) : _rep.Read(m.MatKhau);

            if (m1 == null)
            {
                res.SetError("EZ103", "No Data");
            }
            else
            {
                res      = base.Update(m);
                res.Data = m;
            }

            return(res);
        }
 public IActionResult getDiembySBD([FromBody] SimpleReq req)
 {
     try
     {
         var res  = new SingleRsp();
         var diem = _svc.GetBySBD(req.Keyword);
         if (!(diem is null))
         {
             res.Data = diem;
             return(Ok(res));
         }
         return(NotFound());
     }
     catch (Exception)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data from database"));
     }
 }
Example #22
0
        public SingleRsp updateGiaoVien(GiaoVienReq gv)
        {
            var      res   = new SingleRsp();
            GiaoVien newGV = new GiaoVien();

            newGV.MaGv     = gv.MaGv;
            newGV.TenGv    = gv.TenGv;
            newGV.MaMh     = gv.MaMh;
            newGV.MaLop    = gv.MaLop;
            newGV.NgaySinh = gv.NgaySinh;
            newGV.GioiTinh = gv.GioiTinh;
            newGV.DiaChi   = gv.DiaChi;
            newGV.SoDt     = gv.SoDt;

            res = _rep.UpdateGiaoVien(newGV);
            //res.Data = newGV;
            return(res);
        }
Example #23
0
        public SingleRsp UpdateProduct(ProductsReq pro)
        {
            var      res      = new SingleRsp();
            Products products = new Products();

            products.ProductId   = pro.ProductId;
            products.CategoryId  = pro.CategoryId;
            products.ProductName = pro.ProductName;
            products.Price       = pro.Price;
            products.Stock       = pro.Stock;
            products.DateCreate  = pro.DateCreate;
            products.Description = pro.Description;
            products.ImageSource = pro.ImageSource;
            products.PromotionId = pro.PromotionId;

            res = _rep.UpdateProduct(products);
            return(res);
        }
Example #24
0
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="m">The model</param>
        /// <returns>Return the result</returns>
        public override SingleRsp Update(Categories m)
        {
            var res = new SingleRsp();

            var m1 = m.CategoryId > 0 ? _rep.Read(m.CategoryId) : _rep.Read(m.Description);

            if (m1 == null)
            {
                res.SetError("EZ103", "No data.");
            }
            else
            {
                res      = base.Update(m);
                res.Data = m;
            }

            return(res);
        }
Example #25
0
        public SingleRsp UpdateProduct(ProductssReq pro)
        {
            var       res      = new SingleRsp();
            Productss products = new Productss();

            products = _rep.Read(pro.ProductId.Value);

            products.ProductName = pro.ProductName;
            products.CategoryId  = pro.CategoryId;
            products.SupplierId  = pro.SupplierId;
            products.UnitPrice   = pro.UnitPrice;
            products.UnitInStock = pro.UnitInStock;
            products.Color       = pro.Color;
            products.Image       = pro.Image;

            res = _rep.UpdateProduct(products);
            return(res);
        }
Example #26
0
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="m">The model</param>
        /// <returns>Return the result</returns>
        public override SingleRsp Update(ThiSinh m)
        {
            var res = new SingleRsp();

            var m1 = m.SoBaoDanh != null?_rep.Read(m.SoBaoDanh) : _rep.Read(m.SoBaoDanh);

            if (m1 == null)
            {
                res.SetError("EZ103", "No data.");
            }
            else
            {
                res      = base.Update(m);
                res.Data = m;
            }

            return(res);
        }
        public SingleRsp UpdateOrder(OrderReq ord)
        {
            var   res  = new SingleRsp();
            Order ords = new Order();

            ords.OrderId         = ord.OrderId;
            ords.CustomerId      = ord.CustomerId;
            ords.StatusId        = ord.StatusId;
            ords.DelivererId     = ord.DelivererId;
            ords.CreateDate      = ord.CreateDate;
            ords.TotalPrice      = ord.TotalPrice;
            ords.DeliveryAddress = ord.DeliveryAddress;
            ords.Note            = ord.Note;

            res = _rep.UpdateOrder(ords);

            return(res);
        }
Example #28
0
        public SingleRsp UpdateProduct(ProductReq pro)
        {
            var      res  = new SingleRsp();
            Products prod = new Products();

            prod.ProductId      = pro.ProductId;
            prod.Name           = pro.Name;
            prod.Detail         = pro.Detail;
            prod.Price          = pro.Price;
            prod.Image          = pro.Image;
            prod.PriceNew       = pro.PriceNew;
            prod.Date           = pro.Date;
            prod.Status         = pro.Status;
            prod.GroupProductId = pro.GroupProductId;
            res = _rep.UpdateProduct(prod);

            return(res);
        }
Example #29
0
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="m">The model</param>
        /// <returns>Return the result</returns>
        public override SingleRsp Update(Product m)
        {
            var res = new SingleRsp();

            var m1 = m.ProductId != null?_rep.Read(m.ProductId) : _rep.Read(m.ProductId);

            if (m1 == null)
            {
                res.SetError("EZ103", "No data.");
            }
            else
            {
                res      = base.Update(m);
                res.Data = m;
            }

            return(res);
        }
        public override SingleRsp Update(LoaiSanPham m)
        {
            var res = new SingleRsp();

            var m1 = m.IdLoai > 0 ? _rep.Read(m.IdLoai) : _rep.Read(m.TenLoai);

            if (m1 == null)
            {
                res.SetError("EZ103", "No data.");
            }
            else
            {
                res      = base.Update(m);
                res.Data = m;
            }

            return(res);
        }