Ejemplo n.º 1
0
 private void AddCustomer()
 {
     if (CustomerNameTextBox.Text.Length > 3 && CustomerCodeTextBox.Text.Length > 3)
     {
         Customer cust = new Customer()
         {
             CustomerCode = CustomerCodeTextBox.Text,
             Name         = CustomerNameTextBox.Text,
             EntryDate    = DateTime.Now
         };
         if (context.Customers.SingleOrDefault(c => c.CustomerCode == cust.CustomerCode) != null)
         {
             MessageBox.Show("Cannot create duplicate");
         }
         else
         {
             context.Customers.Add(cust);
             context.SaveChanges();
         }
     }
     else
     {
         CustomerNameTextBox.Select();
     }
 }
Ejemplo n.º 2
0
        public JsonResult SaveSales([FromBody] Sales sales)
        {
            var newsales = _context.Sales;

            newsales.Add(sales);
            _context.SaveChanges();
            var salesDetails = _context.SalesDetails.Where(p => p.TransctionID == sales.TransctionID);

            return(Json(salesDetails));
        }
Ejemplo n.º 3
0
        public static bool Update(DetailReturPenjualanViewModel model)
        {
            bool result = true;

            try
            {
                using (var db = new PosContext())
                {
                    if (model.Id == 0)
                    {
                        DetailPenjualan detailPenjualan = new DetailPenjualan();
                        detailPenjualan.Id = model.Id;
                        detailPenjualan.IdHeaderPenjualan   = model.IdHeaderPenjualan;
                        detailPenjualan.IdBarang            = model.IdBarang;
                        detailPenjualan.HargaPenjualan      = model.HargaPenjualan;
                        detailPenjualan.JumlahBarang        = model.JumlahBarang;
                        detailPenjualan.Total               = model.Total;
                        detailPenjualan.JumlahPengembalian  = model.JumlahPengembalian;
                        detailPenjualan.TanggalPengembalian = model.TanggalPengembalian;
                        detailPenjualan.AlasanPengembalian  = model.AlasanPengembalian;
                        detailPenjualan.CreatedBy           = "Arief";
                        detailPenjualan.CreatedDate         = DateTime.Now;

                        db.Trans_DetailPenjualans.Add(detailPenjualan);
                        db.SaveChanges();
                    }
                    else
                    {
                        DetailPenjualan detailPenjualan = db.Trans_DetailPenjualans.Where(d => d.Id == model.Id).FirstOrDefault();
                        if (detailPenjualan != null)
                        {
                            detailPenjualan.IdHeaderPenjualan   = model.IdHeaderPenjualan;
                            detailPenjualan.IdBarang            = model.IdBarang;
                            detailPenjualan.HargaPenjualan      = model.HargaPenjualan;
                            detailPenjualan.JumlahBarang        = model.JumlahBarang;
                            detailPenjualan.Total               = model.Total;
                            detailPenjualan.JumlahPengembalian  = model.JumlahPengembalian;
                            detailPenjualan.TanggalPengembalian = model.TanggalPengembalian;
                            detailPenjualan.AlasanPengembalian  = model.AlasanPengembalian;
                            detailPenjualan.ModifiedBy          = "Arief";
                            detailPenjualan.ModifiedDate        = DateTime.Now;

                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result  = false;
                Message = ex.Message;
            }

            return(result);
        }
Ejemplo n.º 4
0
        public static bool Update(PembeliViewModel model)
        {
            bool result = true;

            try
            {
                using (var db = new PosContext())
                {
                    if (model.Id == 0)
                    {
                        Pembeli pembeli = new Pembeli();
                        pembeli.Id           = model.Id;
                        pembeli.NoMember     = model.NoMember;
                        pembeli.NamaDepan    = model.NamaDepan;
                        pembeli.NamaTengah   = model.NamaTengah;
                        pembeli.NamaBelakang = model.NamaBelakang;
                        pembeli.Alamat       = model.Alamat;
                        pembeli.TempatLahir  = model.TempatLahir;
                        pembeli.TanggalLahir = model.TanggalLahir;
                        pembeli.JenisKelamin = model.JenisKelamin;
                        pembeli.IsActivated  = model.IsActivated;
                        pembeli.CreatedBy    = "Rio";
                        pembeli.CreatedDate  = DateTime.Now;
                        db.Mst_Pembelis.Add(pembeli);
                        db.SaveChanges();
                    }
                    else
                    {
                        Pembeli pembeli = db.Mst_Pembelis.Where(o => o.Id == model.Id).FirstOrDefault();
                        if (pembeli != null)
                        {
                            pembeli.NoMember     = model.NoMember;
                            pembeli.NamaDepan    = model.NamaDepan;
                            pembeli.NamaTengah   = model.NamaTengah;
                            pembeli.NamaBelakang = model.NamaBelakang;
                            pembeli.Alamat       = model.Alamat;
                            pembeli.TempatLahir  = model.TempatLahir;
                            pembeli.TanggalLahir = model.TanggalLahir;
                            pembeli.JenisKelamin = model.JenisKelamin;
                            pembeli.IsActivated  = model.IsActivated;
                            pembeli.ModifiedBy   = "Rio";
                            pembeli.ModifiedDate = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result  = false;
                Message = ex.Message;
            }

            return(result);
        }
Ejemplo n.º 5
0
        public static bool Update(KaryawanViewModel model)
        {
            bool result = true;

            try
            {
                using (var db = new PosContext())
                {
                    if (model.Id == 0)
                    {
                        Karyawan karyawan = new Karyawan();
                        karyawan.Id           = model.Id;
                        karyawan.NoInduk      = model.NoInduk;
                        karyawan.NamaDepan    = model.NamaDepan;
                        karyawan.NamaTengah   = model.NamaTengah;
                        karyawan.NamaBelakang = model.NamaBelakang;
                        karyawan.Alamat       = model.Alamat;
                        karyawan.TempatLahir  = model.TempatLahir;
                        karyawan.TanggalLahir = model.TanggalLahir;
                        karyawan.JenisKelamin = model.JenisKelamin;
                        karyawan.IsActivated  = model.IsActivated;
                        karyawan.CreatedBy    = "Rio";
                        karyawan.CreatedDate  = DateTime.Now;
                        db.Mst_Karyawans.Add(karyawan);
                        db.SaveChanges();
                    }
                    else
                    {
                        Karyawan karyawan = db.Mst_Karyawans.Where(o => o.Id == model.Id).FirstOrDefault();
                        if (karyawan != null)
                        {
                            karyawan.NoInduk      = model.NoInduk;
                            karyawan.NamaDepan    = model.NamaDepan;
                            karyawan.NamaTengah   = model.NamaTengah;
                            karyawan.NamaBelakang = model.NamaBelakang;
                            karyawan.Alamat       = model.Alamat;
                            karyawan.TempatLahir  = model.TempatLahir;
                            karyawan.TanggalLahir = model.TanggalLahir;
                            karyawan.JenisKelamin = model.JenisKelamin;
                            karyawan.IsActivated  = model.IsActivated;
                            karyawan.ModifiedBy   = "Rio";
                            karyawan.ModifiedDate = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result  = false;
                Message = ex.Message;
            }

            return(result);
        }
        public ActionResult Create([Bind(Include = "ID,Name,Address,Tel,Creditlimit")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customer.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
Ejemplo n.º 7
0
        public ActionResult Create([Bind(Include = "ID,Name,Active")] Item item)
        {
            if (ModelState.IsValid)
            {
                db.Item.Add(item);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(item));
        }
        public ActionResult Create([Bind(Include = "ID,EffectiveDate,UnitPrice,Active,ItemID")] ItemDetail itemDetail)
        {
            if (ModelState.IsValid)
            {
                db.ItemDetail.Add(itemDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ItemID = new SelectList(db.Item, "ID", "Name", itemDetail.ItemID);
            return(View(itemDetail));
        }
        public ActionResult Create([Bind(Include = "ID,InvoiceDate,ItemTotal,Discount,Tax,InvoiceTotal,CustomerID")] Invoice invoice)
        {
            if (ModelState.IsValid)
            {
                db.Invoice.Add(invoice);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.CustomerID = new SelectList(db.Customer, "ID", "Name", invoice.CustomerID);
            return View(invoice);
        }
Ejemplo n.º 10
0
        public ActionResult Create([Bind(Include = "Id,Name,Address,Email,WebAddress,Phone,FinancialYearId")] Shop shop)
        {
            if (ModelState.IsValid)
            {
                db.Shops.Add(shop);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.FinancialYearId = new SelectList(db.FinancialYears, "Id", "Name", shop.FinancialYearId);
            return(View(shop));
        }
Ejemplo n.º 11
0
        public ActionResult Create([Bind(Include = "Id,Name,Stock,BarCode,ShopId,MeasurementId")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MeasurementId = new SelectList(db.Measurements, "Id", "Name", product.MeasurementId);
            ViewBag.ShopId        = new SelectList(db.Shops, "Id", "Name", product.ShopId);
            return(View(product));
        }
Ejemplo n.º 12
0
        //Create dan Edit
        public static bool Update(BarangViewModel model)
        {
            bool result = true;

            try
            {
                using (var db = new PosContext())
                {
                    if (model.Id == 0)
                    {
                        Barang barang = new Barang();
                        barang.Id   = model.Id;
                        barang.Code = model.Code;
                        //barang.IdSupplier = model.IdSupplier;
                        barang.Deskripsi = model.Deskripsi;
                        //barang.Harga = model.Harga;
                        //barang.Stok = model.Stok;
                        barang.IsActivated = model.IsActivated;
                        barang.CreatedBy   = "Arief";
                        barang.CreatedDate = DateTime.Now;

                        db.Mst_Barangs.Add(barang);
                        db.SaveChanges();
                    }
                    else
                    {
                        Barang barang = db.Mst_Barangs.Where(d => d.Id == model.Id).FirstOrDefault();
                        if (barang != null)
                        {
                            barang.Code = model.Code;
                            //barang.IdSupplier = model.IdSupplier;
                            barang.Deskripsi = model.Deskripsi;
                            //barang.Harga = model.Harga;
                            //barang.Stok = model.Stok;
                            barang.IsActivated  = model.IsActivated;
                            barang.ModifiedBy   = "Arief";
                            barang.ModifiedDate = DateTime.Now;

                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result  = false;
                Message = ex.Message;
            }

            return(result);
        }
Ejemplo n.º 13
0
        public static int CreateLandlord(Landlord entity)
        {
            try
            {

                using (var ctx = new PosContext())
                {
                    var found = ctx.Landlord.FirstOrDefault(a => a.Email == entity.Email);
                    if (found == null)
                    {
                        var model = ctx.Landlord.Add(entity);
                        ctx.SaveChanges();
                        AgencyContext.AddNewLandlord(model);
                        return model.Id;
                    }
                    else
                    {
                        //TODO If landlord is found he might have an account, maybe with another agency
                        /*TODO HE May also be created without being invited to the site so he has no login so need to check
                         * TODO whether or not the agency want to link him to one of the entities within their database
                         *
                        */

                    }
                    return -1;

                }

            }
            catch (Exception ex)
            {
                return -1;
            }
        }
Ejemplo n.º 14
0
 private void SaveUser()
 {
     if (isEditing)
     {
         var currentUser = userBindingSource.Current as User;
         if (currentUser != null)
         {
             currentUser.Username = UsernameTextBox.Text;
             currentUser.Password = encryptor.GetEncrypted(PasswordTextBox.Text);
             currentUser.Role     = (Role)RoleComboBox.SelectedItem;
         }
     }
     else
     {
         var user = new User
         {
             Username = UsernameTextBox.Text,
             Password = encryptor.GetEncrypted(PasswordTextBox.Text),
             Role     = (Role)RoleComboBox.SelectedItem
         };
         context.Users.Add(user);
     }
     context.SaveChanges();
     EditUser(false);
     UsernameTextBox.Clear();
     PasswordTextBox.Clear();
 }
Ejemplo n.º 15
0
        public static int CreateLog(Log log)
        {
            try
            {

                using (var ctx = new PosContext())
                {
                    var email = HttpContext.Current.User.Identity.Name;
                    log.CreatedByEmail = email;
                    var found = ctx.Log.FirstOrDefault(a => a.Id == log.Id);

                    if (found == null)
                    {

                        log.CreatedDateTime = DateTime.Now;
                        var model = ctx.Log.Add(log);
                        ctx.SaveChanges();
                        return model.Id;
                    }
                    return -1;

                }

            }
            catch (Exception ex)
            {
                return -1;
            }
        }
Ejemplo n.º 16
0
        //Create dan Edit
        public static bool Update(SupplierViewModel model)
        {
            bool result = true;

            try
            {
                using (var db = new PosContext())
                {
                    if (model.Id == 0)
                    {
                        Supplier supplier = new Supplier();
                        supplier.Id          = model.Id;
                        supplier.Nama        = model.Nama;
                        supplier.Alamat      = model.Alamat;
                        supplier.NoTelp      = model.NoTelp;
                        supplier.IsActivated = model.IsActivated;
                        supplier.CreatedBy   = "Arief";
                        supplier.CreatedDate = DateTime.Now;

                        db.Mst_Suppliers.Add(supplier);
                        db.SaveChanges();
                    }
                    else
                    {
                        Supplier supplier = db.Mst_Suppliers.Where(d => d.Id == model.Id).FirstOrDefault();
                        if (supplier != null)
                        {
                            supplier.Nama         = model.Nama;
                            supplier.Alamat       = model.Alamat;
                            supplier.NoTelp       = model.NoTelp;
                            supplier.IsActivated  = model.IsActivated;
                            supplier.ModifiedBy   = "Arief";
                            supplier.ModifiedDate = DateTime.Now;

                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result  = false;
                Message = ex.Message;
            }

            return(result);
        }
Ejemplo n.º 17
0
 public void Remove(string productName)
 {
     using (var db = new PosContext())
     {
         db.Products.Remove(db.Products.Where(p => p.ProductName == productName).FirstOrDefault());
         db.SaveChanges();
     }
 }
Ejemplo n.º 18
0
 public void CancelReservation(int selectedReservationID)
 {
     using (var db = new PosContext())
     {
         db.Reservations.Remove(db.Reservations.Find(selectedReservationID));
         db.SaveChanges();
     }
 }
Ejemplo n.º 19
0
 public void Delete(string table)
 {
     using (var db = new PosContext())
     {
         db.Tables.Remove(db.Tables.Where(t => t.TableName == table).FirstOrDefault());
         db.SaveChanges();
     }
 }
Ejemplo n.º 20
0
 public void UpdateTableStatus(string tableName, int statusID)
 {
     using (var db = new PosContext())
     {
         db.Tables.Where(t => t.TableName == tableName).FirstOrDefault().TableStatusID = statusID;
         db.SaveChanges();
     }
 }
Ejemplo n.º 21
0
 public void Delete(int id)
 {
     using (var db = new PosContext())
     {
         db.Users.Remove(db.Users.Find(id));
         db.SaveChanges();
     }
 }
Ejemplo n.º 22
0
 public void Update(string name, string newName)
 {
     using (var db = new PosContext())
     {
         db.Allergens.Where(a => a.AllergenName == name).Select(a => a).SingleOrDefault().AllergenName = newName;
         db.SaveChanges();
     }
 }
Ejemplo n.º 23
0
 public void Remove(int allergenId)
 {
     using (var db = new PosContext())
     {
         db.Allergens.Remove(db.Allergens.Find(allergenId));
         db.SaveChanges();
     }
 }
Ejemplo n.º 24
0
 public void Delete(string productCategoryName)
 {
     using (var db = new PosContext())
     {
         db.ProductCategories.Remove(db.ProductCategories.Where(pc => pc.ProductCategoryName == productCategoryName).FirstOrDefault());
         db.SaveChanges();
     }
 }
Ejemplo n.º 25
0
 public void SetProductQuantity(Product selectedProduct, int quantity)
 {
     using (var db = new PosContext())
     {
         db.Products.Find(selectedProduct.ProductID).ProductQuantity = quantity;
         db.SaveChanges();
     }
 }
Ejemplo n.º 26
0
        public ActionResult AddorEdit(Customer cust)//we have to pass instance of object in defined stages of enity that's we have created instance
        {
            var CustomerId = new SqlParameter("CustomerId", SqlDbType.Int);

            CustomerId.Value = cust.CustomerId;
            var CustomerName = new SqlParameter("CustomerName", SqlDbType.NVarChar);

            CustomerName.Value = cust.CustomerName;
            var CustomerAddress = new SqlParameter("CustomerAddress", SqlDbType.NVarChar);

            CustomerAddress.Value = cust.CustomerAddress;
            var CustomerGender = new SqlParameter("Gender", SqlDbType.NVarChar);

            CustomerGender.Value = cust.Gender;
            using (PosContext db = new PosContext())
            {
                if (cust.CustomerId == 0 && ModelState.IsValid)
                {
                    /*By using Entity Framework
                     * db.Customers.Add(cust);*/
                    //By using Stored Procedure
                    db.Database.ExecuteSqlCommand("exec Customer_Insert @CustomerName,@CustomerAddress,@Gender", CustomerName, CustomerAddress, CustomerGender);
                    db.SaveChanges();
                    return(Json(new { success = true, message = "saved Successfully" }, JsonRequestBehavior.AllowGet));
                }
                else if (cust.CustomerId != 0 && ModelState.IsValid)
                {
                    /*By using Entity framework
                     * db.Entry(cust).State = EntityState.Modified;*/
                    //By using Stored Procedure
                    db.Database.ExecuteSqlCommand("exec Customer_Update  @CustomerId,@CustomerName,@CustomerAddress,@Gender", CustomerId, CustomerName, CustomerAddress, CustomerGender);
                    db.SaveChanges();
                    return(Json(new { success = true, message = "saved Successfully" }, JsonRequestBehavior.AllowGet));
                }
                else if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("CustomerName", "Name is Required");
                    return(View());
                }
                else
                {
                    return(View(cust));
                }
            }
        }
Ejemplo n.º 27
0
 public void Update(string productCategoryName, string newProductCategoryName)
 {
     using (var db = new PosContext())
     {
         db.ProductCategories.Where(pc => pc.ProductCategoryName == productCategoryName)
         .Select(pc => pc).FirstOrDefault().ProductCategoryName = newProductCategoryName;
         db.SaveChanges();
     }
 }
Ejemplo n.º 28
0
 public ActionResult AddorEdit_Product(Product prod)//we have to pass instance of object in defined stages of enity that's we have created instance
 {
     using (PosContext db = new PosContext())
     {
         if (prod.ProductId == 0)
         {
             db.Products.Add(prod);
             db.SaveChanges();
             return(Json(new { success = true, message = "saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Entry(prod).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }
Ejemplo n.º 29
0
 public void Update(int tableID, string tableName, int tableSteats, string tableSite)
 {
     using (var db = new PosContext())
     {
         db.Tables.Where(t => t.TableID == tableID).FirstOrDefault().TableName  = tableName;
         db.Tables.Where(t => t.TableID == tableID).FirstOrDefault().TableSeats = tableSteats;
         db.Tables.Where(t => t.TableID == tableID).FirstOrDefault().TableSite  = tableSite;
         db.SaveChanges();
     }
 }
Ejemplo n.º 30
0
        public static bool Update(TokoViewModel model)
        {
            bool result = true;

            try
            {
                using (var db = new PosContext())
                {
                    if (model.Id == 0)
                    {
                        Toko toko = new Toko();
                        toko.Id          = model.Id;
                        toko.Nama        = model.Nama;
                        toko.Alamat      = model.Alamat;
                        toko.NoTelp      = model.NoTelp;
                        toko.CreatedBy   = "Rio";
                        toko.CreatedDate = DateTime.Now;
                        db.Mst_Tokos.Add(toko);
                        db.SaveChanges();
                    }
                    else
                    {
                        Toko toko = db.Mst_Tokos.Where(o => o.Id == model.Id).FirstOrDefault();
                        if (toko != null)
                        {
                            toko.Nama         = model.Nama;
                            toko.Alamat       = model.Alamat;
                            toko.NoTelp       = model.NoTelp;
                            toko.ModifiedBy   = "Rio";
                            toko.ModifiedDate = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result  = false;
                Message = ex.Message;
            }

            return(result);
        }
Ejemplo n.º 31
0
 public ActionResult Delete_Product(int id)
 {
     using (PosContext db = new PosContext())
     {
         Product prod = db.Products.Where(x => x.ProductId == id).FirstOrDefault <Product>();
         db.Products.Remove(prod);
         db.SaveChanges();
         return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 32
0
 public void Create(string productCategoryName)
 {
     using (var db = new PosContext())
     {
         db.ProductCategories.Add(new ProductCategory {
             ProductCategoryName = productCategoryName
         });
         db.SaveChanges();
     }
 }
Ejemplo n.º 33
0
        internal static SingleUseEntity GenerateUniqueCode(string email, string userType)
        {
            Agency agency = GetCurrentUser();
            using (var ctx = new PosContext())
            {
                var model = from s in ctx.SingleUse
                            where s.email == email
                            select s;

                if (model.Any())
                {
                    var singleusecode = model.FirstOrDefault();
                    if (singleusecode != null)
                    {
                        singleusecode.SUC = Guid.NewGuid();

                        ctx.SaveChanges();

                        return singleusecode;
                    }
                }

                var suc = new SingleUseEntity
                {
                    AgencyId = agency.Id,
                    SUC = Guid.NewGuid(),
                    GeneratedCodeTime = DateTime.UtcNow,
                    email = email,
                    UserType = userType
                };

                ctx.SingleUse.Add(suc);

                ctx.SaveChanges();

                return suc;
            }
        }
Ejemplo n.º 34
0
        public static int CreateFile(File model)
        {
            try
            {
                using (var ctx = new PosContext())
                {
                    ctx.File.Add(model);
                    ctx.SaveChanges();
                    return model.Id;
                }

            }
            catch (Exception ex)
            {
                return -1;
            }
        }
Ejemplo n.º 35
0
        public static Landlord AddNewLandlord(Landlord entity)
        {
            try
            {
                using (var ctx = new PosContext())

                {
                    Agency thisAgency = GlobalVariables.GetAgentsAgency;
                    AgencyLandlords AgencyLandlord = new AgencyLandlords
                    {
                        AgencyId = thisAgency.Id,
                        LandlordId = entity.Id
                    };
                    ctx.AgencyLandlords.Add(AgencyLandlord);
                    ctx.SaveChanges();
                    return (entity);
                }

            }
            catch (Exception ex)
            {
                return null;
            }
        }
Ejemplo n.º 36
0
        public static int CreateProperty(Property entity)
        {
            try
            {

                using (var ctx = new PosContext())
                {
                    var found = ctx.Property.FirstOrDefault(a => a.Id == entity.Id);
                    if (found == null)
                    {
                        var model = ctx.Property.Add(entity);
                        ctx.SaveChanges();
                        return model.Id;
                    }
                    return -1;

                }

            }
            catch (Exception ex)
            {
                return -1;
            }
        }
Ejemplo n.º 37
0
        public static bool CreateAgent(Agent agent)
        {
            try
            {

                using (var ctx = new PosContext())
                {
                    var found = ctx.Agent.FirstOrDefault(a => a.UserId == agent.UserId);
                    if (found == null)
                    {
                        ctx.Agent.Add(agent);
                        ctx.SaveChanges();
                        return true;
                    }
                    return false;

                }

            }
            catch (Exception ex)
            {
                return false;
            }
        }
Ejemplo n.º 38
0
        public static bool InsertLogArchive(Log log)
        {
            try
            {

                using (var ctx = new PosContext())
                {
                    log.Archived = true;
                    //get email of logged on user --cast agency to user?!?!?
                    var email = GlobalVariables.CurrentUserEmail;
                    if (log != null)
                    {
                        var archive = new LogArchive
                        {
                            Log = log,
                            DateTimeArchived = DateTime.Now,
                            ArchivedByUserEmail = email
                        };
                        ctx.LogArchive.Add(archive);

                        ctx.SaveChanges();
                        return true;
                    }

                }

            }
            catch (Exception ex)
            {
                return false;
            }
            return false;
        }
Ejemplo n.º 39
0
        public static bool UpdateLog(Log entity)
        {
            try
            {
                using (var ctx = new PosContext())
                {

                    if (entity == null) throw new ArgumentNullException("Log not found with Id " + entity.Id);
                    InsertLogArchive(entity);
                    ctx.Entry(entity).State = EntityState.Modified;
                    ctx.SaveChanges();
                    return true;
                }

            }
            catch (Exception ex)
            {
                return false;
            }
        }