Beispiel #1
0
        public IHttpActionResult insertNewSanPhamYeuThich([FromBody] SanPhamYeuThich sanPhamYeuThich)
        {
            try
            {
                SanPhamYeuThich sp = db.SanPhamYeuThiches.FirstOrDefault(x => x.id_san_pham == sanPhamYeuThich.id_san_pham &&
                                                                         x.id_khach_hang == sanPhamYeuThich.id_khach_hang);

                if (sp != null)
                {
                    return(StatusCode(HttpStatusCode.NoContent));
                }

                db.SanPhamYeuThiches.InsertOnSubmit(sanPhamYeuThich);
                db.SubmitChanges();

                var tam = new
                {
                    id_yeu_thich  = sanPhamYeuThich.id_yeu_thich,
                    id_san_pham   = sanPhamYeuThich.id_san_pham,
                    id_khach_hang = sanPhamYeuThich.id_khach_hang,
                };

                return(Ok(tam));
            }catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        [ActionName("them")] //truyen vao cac thuoc tinh
        public IHttpActionResult insertNewTinhTrangDonHang([FromBody] TinhTrangDonHang tinhTrangDonHang)
        {
            try
            {
                TinhTrangDonHang tr = db.TinhTrangDonHangs.FirstOrDefault(e => e.tinh_trang_don_hang.Equals(tinhTrangDonHang.tinh_trang_don_hang));
                if (tr == null)
                {
                    var tam = new
                    {
                        id_tinh_trang       = tr.id_tinh_trang,
                        tinh_trang_don_hang = tr.tinh_trang_don_hang,
                        ghi_chu             = tr.ghi_chu
                    };
                    return(Ok(tam));
                }

                db.TinhTrangDonHangs.InsertOnSubmit(tinhTrangDonHang);
                db.SubmitChanges();
                var tinhTrang = new
                {
                    id_tinh_trang       = tinhTrangDonHang.id_tinh_trang,
                    tinh_trang_don_hang = tinhTrangDonHang.tinh_trang_don_hang,
                    ghi_chu             = tinhTrangDonHang.ghi_chu
                };
                return(Ok(tinhTrang));
            } catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Beispiel #3
0
        public IHttpActionResult themHinh([FromBody] hinhAnh hinh)
        {
            try
            {
                if (db.SanPhams.FirstOrDefault(e => e.id_san_pham == hinh.idSanpham) == null)
                {
                    return(StatusCode(HttpStatusCode.NotFound));
                }

                for (int i = 0; i < hinh.base64.Count; i++)
                {
                    HinhSP hinhTam = new HinhSP();
                    hinhTam.id_sp = hinh.idSanpham;

                    byte[]       imageBytes = Convert.FromBase64String(hinh.base64[i]);
                    MemoryStream ms         = new MemoryStream(imageBytes, 0, imageBytes.Length);
                    ms.Write(imageBytes, 0, imageBytes.Length);
                    System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);
                    string fileName            = hinh.idSanpham + "stt" + i + ".png";
                    image.Save(Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~/hinh/SanPham"), fileName));

                    hinhTam.url_hinh = "~/hinh/SanPham/" + fileName;

                    db.HinhSPs.InsertOnSubmit(hinhTam);
                    db.SubmitChanges();
                }
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Beispiel #4
0
        public IHttpActionResult insert([FromBody] DiaChiKhachHang diaChi)
        {
            try
            {
                DiaChiKhachHang dc = db.DiaChiKhachHangs.FirstOrDefault(e => e.so_dt == diaChi.so_dt &&
                                                                        e.id_khach_hang == diaChi.id_khach_hang &&
                                                                        e.id_xa_phuong == diaChi.id_xa_phuong &&
                                                                        e.dia_chi.Equals(diaChi.dia_chi));
                if (dc != null)
                {
                    return(StatusCode(HttpStatusCode.NoContent));
                }
                diaChi.trang_thai = true;
                db.DiaChiKhachHangs.InsertOnSubmit(diaChi);
                db.SubmitChanges();

                DiaChiKhachHang tam = new DiaChiKhachHang();
                tam.id             = diaChi.id;
                tam.id_khach_hang  = diaChi.id_khach_hang;
                tam.id_quan        = diaChi.id_quan;
                tam.id_tinh        = diaChi.id_tinh;
                tam.id_xa_phuong   = diaChi.id_xa_phuong;
                tam.loai           = diaChi.loai;
                tam.dia_chi        = diaChi.dia_chi;
                tam.so_dt          = diaChi.so_dt;
                tam.ten_khach_hang = diaChi.ten_khach_hang;
                return(Ok(tam));
            }catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Beispiel #5
0
        public IHttpActionResult InsertNewDanhMucSanPham([FromBody] DanhMucSanPham danhMucSanPham)
        {
            try
            {
                // copy data của hình ảnh. khi
                // data của ảnh sẽ được xóa trước khi lưu database
                // chỉ lưu lại url của ảnh vào database
                string base64 = danhMucSanPham.url_hinh;
                // kiểm tra thông tin đầu vào
                if (string.IsNullOrEmpty(danhMucSanPham.ten_danh_muc) || string.IsNullOrEmpty(danhMucSanPham.url_hinh))
                {
                    return(BadRequest(new ResponseData
                    {
                        ResponseMessage = "Thông tin nhập chưa đúng",
                        ResponseCode = 1
                    }.ToString()));
                }
                // kiểm tra danh mục đã tồn tại
                DanhMucSanPham dsp = db.DanhMucSanPhams.FirstOrDefault(e => e.ten_danh_muc.Equals(danhMucSanPham.ten_danh_muc));
                if (dsp != null)
                {
                    // lưu database
                    danhMucSanPham.url_hinh = "";
                    db.DanhMucSanPhams.InsertOnSubmit(danhMucSanPham);
                    db.SubmitChanges();

                    // lưu ảnh vào server
                    byte[]       imageBytes = Convert.FromBase64String(base64);
                    MemoryStream ms         = new MemoryStream(imageBytes, 0, imageBytes.Length);
                    ms.Write(imageBytes, 0, imageBytes.Length);
                    System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);
                    string fileName            = "danh_muc_" + danhMucSanPham.id_danh_muc + ".png";
                    image.Save(Path.Combine(HostingEnvironment.MapPath("~/hinh/DanhMuc"), fileName));

                    // update lại url hình ảnh vào db
                    danhMucSanPham.url_hinh = "/hinh/DanhMuc/" + fileName;
                    db.SubmitChanges();
                }
                return(Ok(new ResponseData
                {
                    ResponseCode = 2,
                    ResponseMessage = "Thành công"
                }.ToString()));
            }
            catch (Exception ex)
            {
                return(Ok(new ResponseData
                {
                    ResponseCode = 1,
                    ResponseMessage = ex.Message
                }.ToString()));
            }
        }
 public IHttpActionResult insertNewChiTietDonHang([FromBody] ChiTietDonHang chiTietDonHang)
 {
     try
     {
         db.ChiTietDonHangs.InsertOnSubmit(chiTietDonHang);
         db.SubmitChanges();
         return(Ok(chiTietDonHang));
     }catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Beispiel #7
0
 public bool Update(HOADON hd, out string message)
 {
     message = "";
     try
     {
         QuanLyBanHangDataContext context = new QuanLyBanHangDataContext();
         HOADON hoadon = context.HOADONs.FirstOrDefault(x => x.MaHD == hd.MaHD);
         if (hoadon != null)
         {
             hoadon.Ngay      = hd.Ngay;
             hoadon.Thang     = hd.Thang;
             hoadon.Nam       = hd.Nam;
             hoadon.TongGiaSP = hd.TongGiaSP;
             hoadon.TongTien  = hd.TongTien;
             hoadon.TT_HD     = hd.TT_HD;
             context.SubmitChanges();
             return(true);
         }
         message = "Khong co gia tri";
         return(false);
     }
     catch (Exception e)
     {
         message = e.Message;
     }
     return(false);
 }
Beispiel #8
0
 public bool Update(NHANVIEN nv, out string message)
 {
     message = "";
     try
     {
         QuanLyBanHangDataContext context = new QuanLyBanHangDataContext();
         NHANVIEN nhanvien = context.NHANVIENs.FirstOrDefault(x => x.MaNV == nv.MaNV);
         if (nhanvien != null)
         {
             nhanvien.HoTen      = nv.HoTen;
             nhanvien.CMND       = nv.CMND;
             nhanvien.GT         = nv.GT;
             nhanvien.MatKhau    = nv.MatKhau;
             nhanvien.SDT        = nv.SDT;
             nhanvien.QuanLi     = nv.QuanLi;
             nhanvien.TT_LamViec = nv.TT_LamViec;
             context.SubmitChanges();
             return(true);
         }
         message = "Khong co gia tri";
         return(false);
     }
     catch (Exception e)
     {
         message = e.Message;
     }
     return(false);
 }
Beispiel #9
0
 public bool Update(SANPHAM sp, out string message)
 {
     message = "";
     try
     {
         QuanLyBanHangDataContext context = new QuanLyBanHangDataContext();
         SANPHAM sanpham = context.SANPHAMs.FirstOrDefault(x => x.MaSP == sp.MaSP);
         if (sanpham != null)
         {
             sanpham.TenSP  = sp.TenSP;
             sanpham.HinhSP = sp.HinhSP;
             sanpham.GiaSP  = sp.GiaSP;
             sanpham.GiaBan = sp.GiaBan;
             sanpham.TT_Ban = sp.TT_Ban;
             context.SubmitChanges();
             return(true);
         }
         message = "Khong co gia tri";
         return(false);
     }
     catch (Exception e)
     {
         message = e.Message;
     }
     return(false);
 }
Beispiel #10
0
        public IHttpActionResult themHoaDon([FromBody] TaoDonHang donHang)
        {
            try
            {
                //tao 1 don dat hang
                DonDatHang ddh = new DonDatHang();
                ddh.id_khach_hang    = donHang.idKhachHang;
                ddh.id_tinh_trang    = donHang.idTinhTrang;
                ddh.ngay_lap         = donHang.ngayLap;
                ddh.tong_tien        = donHang.tongTien;
                ddh.so_dt_nguoi_nhan = donHang.soDT;
                ddh.id_dia_chi       = donHang.idNoiNhan;
                ddh.ghi_chu          = donHang.ghiChu;
                db.DonDatHangs.InsertOnSubmit(ddh);
                db.SubmitChanges();
                //tao chi tiet don dat hang tuong ung
                DonDatHang tam = db.DonDatHangs.Where(x => x.id_khach_hang == donHang.idKhachHang).ToList().Last();

                for (int i = 0; i < donHang.danhSachSanPham.Count; i++)
                {
                    ChiTietDonHang ctDonHang = new ChiTietDonHang();
                    int            id        = donHang.danhSachSanPham[i].idSanPham;
                    ctDonHang.id_don_hang   = tam.id_don_hang;
                    ctDonHang.id_san_pham   = donHang.danhSachSanPham[i].idSanPham;
                    ctDonHang.gia_km        = donHang.danhSachSanPham[i].giaKM;
                    ctDonHang.so_luong      = donHang.danhSachSanPham[i].soLuong;
                    ctDonHang.tong_tien     = donHang.danhSachSanPham[i].tongGia;
                    ctDonHang.thoi_gian_lap = donHang.ngayLap;

                    db.ChiTietDonHangs.InsertOnSubmit(ctDonHang);
                    db.SubmitChanges();
                }

                return(Ok(donHang));
            }catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Beispiel #11
0
        public IHttpActionResult uphinh([FromBody] DanhSachKhuyenMai khuyenMai)
        {
            try
            {
                DanhSachKhuyenMai km = db.DanhSachKhuyenMais.FirstOrDefault(e => e.id_khuyen_mai == khuyenMai.id_khuyen_mai);

                byte[]       imageBytes = Convert.FromBase64String(khuyenMai.url_hinh);
                MemoryStream ms         = new MemoryStream(imageBytes, 0, imageBytes.Length);
                ms.Write(imageBytes, 0, imageBytes.Length);
                System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);
                string fileName            = "KhuyenMai_" + km.id_khuyen_mai + ".png";
                image.Save(Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~/hinh/KhuyenMai"), fileName));

                km.url_hinh = "/hinh/KhuyenMai/" + fileName;
                db.SubmitChanges();
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Beispiel #12
0
 public bool EditPC(NHANVIEN nv1, NHANVIEN nv2, CA ca)
 {
     try
     {
         QuanLyBanHangDataContext quanLy = new QuanLyBanHangDataContext();
         PHANCONG pc1 = new PHANCONG();
         pc1.MaNV = nv1.MaNV;
         pc1.MaCa = ca.MaCa;
         pc1.HeSo = 4;
         quanLy.PHANCONGs.DeleteOnSubmit(pc1);
         quanLy.SubmitChanges();
         PHANCONG pc2 = new PHANCONG();
         pc2.MaNV = nv2.MaNV;
         pc2.MaCa = ca.MaCa;
         pc2.HeSo = 4;
         quanLy.PHANCONGs.InsertOnSubmit(pc2);
         quanLy.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #13
0
        public IHttpActionResult taoMoi(string device, string token)
        {
            try
            {
                FCM fcm = db.FCMs.FirstOrDefault(e => e.device.Equals(device) && e.token.Equals(token));

                if (fcm == null)
                {
                    FCM tam = new FCM();
                    tam.device = device;
                    tam.token  = token;

                    db.FCMs.InsertOnSubmit(tam);
                    db.SubmitChanges();

                    return(Ok(tam));
                }
                return(Ok(fcm));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Beispiel #14
0
 public bool Insert(HOADON hd, out string message)
 {
     message = "Thanh toán thành công";
     try
     {
         QuanLyBanHangDataContext context = new QuanLyBanHangDataContext();
         context.HOADONs.InsertOnSubmit(hd);
         context.SubmitChanges();
         return(true);
     }
     catch (Exception e)
     {
         message = e.Message;
     }
     return(false);
 }
Beispiel #15
0
 public bool Insert(NHANVIEN nv, out string message)
 {
     message = "";
     try
     {
         QuanLyBanHangDataContext context = new QuanLyBanHangDataContext();
         context.NHANVIENs.InsertOnSubmit(nv);
         context.SubmitChanges();
         return(true);
     }
     catch (Exception e)
     {
         message = e.Message;
     }
     return(false);
 }
Beispiel #16
0
        //public DataSet GetShifts(int id)
        //{
        //    string str = string.Format("select ca.MaCa " +
        //        "from CA ca inner join PHANCONG pc on ca.MaCa = pc.MaCa" +
        //        " where pc.MaNV={0}",id);
        //    ds.Tables.Add(dbLuong.LoadData(str));
        //    return ds;
        //}

        public void Calculate_salaries(int date)
        {
            QuanLyBanHangDataContext quanLy  = new QuanLyBanHangDataContext();
            List <LUONG>             dsLuong = new List <LUONG>();
            LUONG luong = new LUONG();


            try
            {
                var phancong = (from pc in quanLy.PHANCONGs
                                join ca in quanLy.CAs on pc.MaCa equals ca.MaCa
                                select new OrderView
                {
                    MaNV = pc.MaNV,
                    NgayTL = date,
                    Luong1 = pc.HeSo * ca.LuongCa
                }
                                )
                               .GroupBy(pc => pc.MaNV).AsEnumerable().Select(g => new OrderView
                {
                    MaNV   = g.Key,
                    NgayTL = date,
                    Luong1 = g.Sum(x => x.Luong1)
                });
                List <LUONG> dsl = phancong.Cast <LUONG>().ToList();

                foreach (LUONG item in dsl)
                {
                    LUONG luongg = new LUONG();
                    luongg.MaNV   = item.MaNV;
                    luongg.NgayTL = item.NgayTL;
                    luongg.Luong1 = item.Luong1;
                    quanLy.LUONGs.InsertOnSubmit(luongg);
                    quanLy.SubmitChanges();
                }
                MessageBox.Show("SUCCESS");
            }

            catch
            {
                MessageBox.Show("Đã tính lương tháng này");
            }
            foreach (var item in quanLy.PHANCONGs)
            {
                item.HeSo = 4;
            }
        }
Beispiel #17
0
 public bool AddPC(NHANVIEN nv, CA ca)
 {
     try
     {
         QuanLyBanHangDataContext quanLy = new QuanLyBanHangDataContext();
         PHANCONG pc = new PHANCONG();
         pc.MaNV = nv.MaNV;
         pc.MaCa = ca.MaCa;
         pc.HeSo = 4;
         quanLy.PHANCONGs.InsertOnSubmit(pc);
         quanLy.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #18
0
        public bool Update(PHANCONG pc, out string message)
        {
            QuanLyBanHangDataContext quanLy = new QuanLyBanHangDataContext();
            var que = (from pcc in quanLy.PHANCONGs
                       where pcc.MaCa == pc.MaCa
                       where pcc.MaNV == pc.MaNV
                       select pcc).SingleOrDefault();

            if (que != null)
            {
                que.HeSo = pc.HeSo;
                quanLy.SubmitChanges();
                message = "Success";
                return(true);
            }
            else
            {
                message = "Fail";
                return(false);
            }
        }
Beispiel #19
0
 public bool EditShift(CA ca, int luong)
 {
     try
     {
         QuanLyBanHangDataContext quanLy = new QuanLyBanHangDataContext();
         var que = (from caaa in quanLy.CAs
                    where caaa.MaCa == ca.MaCa
                    select caaa).SingleOrDefault();
         if (que != null)
         {
             que.LuongCa = luong;
             quanLy.SubmitChanges();
             return(true);
         }
         return(false);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #20
0
 public bool Update(CHITIET_HD ct, out string message)
 {
     message = "";
     try
     {
         QuanLyBanHangDataContext context = new QuanLyBanHangDataContext();
         CHITIET_HD chitiet = context.CHITIET_HDs.FirstOrDefault(x => x.MaHD == ct.MaHD && x.MaSP == ct.MaSP);
         if (chitiet != null)
         {
             chitiet.SoLuong = ct.SoLuong;
             context.SubmitChanges();
             return(true);
         }
         message = "Khong co gia tri";
         return(false);
     }
     catch (Exception e)
     {
         message = e.Message;
     }
     return(false);
 }
Beispiel #21
0
 public bool Insert(DOANHTHU_THANG dthu, out string message)
 {
     try
     {
         QuanLyBanHangDataContext quanly = new QuanLyBanHangDataContext();
         DOANHTHU_THANG           dtt    = new DOANHTHU_THANG();
         dtt.NamBH        = dthu.NamBH;
         dtt.ThangBH      = dthu.ThangBH;
         dtt.TongGiaSP_TH = dthu.TongGiaSP_TH;
         dtt.TongLuong_NV = dthu.TongLuong_NV;
         dtt.DoanhThu_TH  = dthu.DoanhThu_TH;
         quanly.DOANHTHU_THANGs.InsertOnSubmit(dtt);
         quanly.SubmitChanges();
         message = "SUCCESS";
         return(true);
     }
     catch
     {
         message = "FAIL";
         return(false);
     }
 }
Beispiel #22
0
        public IHttpActionResult insertNewSanPham([FromBody] SanPham sanPham)
        {
            try
            {
                // kiểm tra thông tin đầu vào
                if (string.IsNullOrEmpty(sanPham.mo_ta) ||
                    string.IsNullOrEmpty(sanPham.ten_sp) ||
                    string.IsNullOrEmpty(sanPham.url_hinh_chinh) ||
                    sanPham.id_danh_muc == 0 ||
                    sanPham.gia_sp == 0
                    )
                {
                    return(Ok(new ResponseData
                    {
                        ResponseCode = 1,
                        ResponseMessage = "Thông tin nhập chưa đúng"
                    }));
                }
                // copy data hình ảnh
                string hinh = sanPham.url_hinh_chinh;

                // insert sản phẩm vào db
                sanPham.url_hinh_chinh = "";
                //kiem tra neu  san pham da co trong db nhung o trang thai da xoa
                SanPham    sp       = db.SanPhams.FirstOrDefault(e => e.id_danh_muc == sanPham.id_danh_muc && e.ten_sp.Equals(sanPham.ten_sp) && e.trang_thai == false);
                ThemHinhSP themhinh = new ThemHinhSP();
                string     tenHinh;
                if (sp != null)
                {
                    tenHinh = themhinh.themHinh(hinh, sanPham.id_san_pham);

                    sp.trang_thai     = true;
                    sp.mo_ta          = sanPham.mo_ta;
                    sp.url_hinh_chinh = "/hinh/SanPham/" + tenHinh;
                    db.SubmitChanges();

                    return(Ok(new ResponseData
                    {
                        ResponseCode = 2,
                        ResponseMessage = "Thành công"
                    }));
                }

                sanPham.trang_thai = true;
                db.SanPhams.InsertOnSubmit(sanPham);
                db.SubmitChanges();

                // save hình vào server
                tenHinh = themhinh.themHinh(hinh, sanPham.id_san_pham);
                //update lai url hinh
                sanPham.url_hinh_chinh = "/hinh/SanPham/" + tenHinh;
                db.SubmitChanges();

                return(Ok(new ResponseData
                {
                    ResponseCode = 2,
                    ResponseMessage = "Thành công"
                }));
            }
            catch (Exception ex)
            {
                return(Ok(new ResponseData
                {
                    ResponseCode = 1,
                    ResponseMessage = ex.Message
                }));
            }
        }
Beispiel #23
0
        public IHttpActionResult DangNhamFCM([FromBody] FCMDangNhap fCMDangNhap)
        {
            try
            {
                KhachHang kh = db.KhachHangs.FirstOrDefault(e => e.so_dt == fCMDangNhap.taiKhoan && e.mat_khau == fCMDangNhap.matKhau && e.trang_thai == true);
                if (kh == null)
                {
                    kh = db.KhachHangs.FirstOrDefault(e => e.email == fCMDangNhap.taiKhoan && e.mat_khau == fCMDangNhap.matKhau && e.trang_thai == true);
                    if (kh == null)
                    {
                        return(StatusCode(HttpStatusCode.NotFound));
                    }
                }
                List <DonDatHang> donHang = db.DonDatHangs.Where(e => e.id_khach_hang == kh.id_khach_hang && e.id_tinh_trang == 5).ToList();
                int   soSanPham           = 0;
                float tongGia             = 0;
                for (int i = 0; i < donHang.Count; i++)
                {
                    tongGia = tongGia + (float)donHang[i].tong_tien;
                    List <ChiTietDonHang> lt = db.ChiTietDonHangs.Where(e => e.id_don_hang == donHang[i].id_don_hang).ToList();
                    soSanPham = soSanPham + lt.Count;
                }
                DateTime ngay = (DateTime)kh.ngay_sinh;
                var      tam  = new
                {
                    id_khach_hang  = kh.id_khach_hang,
                    ten_nguoi_dung = kh.ten_nguoi_dung,
                    ngay_sinh      = ngay.ToShortDateString(),
                    so_dt          = kh.so_dt,
                    gioi_tinh      = kh.gioi_tinh,
                    t_dang_ky      = kh.t_dang_ky.ToShortDateString(),
                    email          = kh.email,
                    url_hinh       = kh.url_hinh,
                    xac_thuc       = kh.xac_thuc,
                    tong_don_hang  = donHang.Count,
                    tong_gia       = tongGia,
                    so_san_pham    = soSanPham
                };
                FCM fcm = db.FCMs.FirstOrDefault(e => e.token.Equals(fCMDangNhap.token) && e.device.Equals(fCMDangNhap.device));
                if (fcm == null)
                {
                    FCM fc = new FCM();

                    fc.khach_hang = tam.id_khach_hang;
                    fc.token      = fCMDangNhap.token;
                    fc.device     = fCMDangNhap.device;

                    db.FCMs.InsertOnSubmit(fc);
                    db.SubmitChanges();
                    return(Ok(tam));
                }

                fcm.khach_hang = tam.id_khach_hang;

                db.SubmitChanges();
                return(Ok(tam));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }