Пример #1
0
 public int Add(quotation_items obj)
 {
     using (var db = new AppDb())
     {
         db.quotation_items.Add(obj);
         var data = db.SaveChanges();
         return(data);
     }
 }
Пример #2
0
 public int Add(invoice_items obj)
 {
     using (var db = new AppDb())
     {
         db.invoice_items.Add(obj);
         var data = db.SaveChanges();
         return(data);
     }
 }
Пример #3
0
 public int Delete(int Id)
 {
     using (var db = new AppDb())
     {
         var data = db.invoice_items.FirstOrDefault(f => f.Id == Id);
         db.invoice_items.Remove(data);
         var result = db.SaveChanges();
         return(result);
     }
 }
Пример #4
0
        public int Add(customer customerData)
        {
            try
            {
                using (var ctx = new AppDb())
                {
                    var obj = ctx.customer.FirstOrDefault(f => f.Id == customerData.Id);
                    if (obj != null)
                    {
                        ctx.Entry(obj).CurrentValues.SetValues(customerData);
                    }
                    else
                    {
                        ctx.customer.Add(customerData);
                    }

                    var plot = ctx.plot.FirstOrDefault(f => f.Id == customerData.PlotID);
                    if (plot != null)
                    {
                        if (customerData.SellAmount != null)
                        {
                            plot.SellAmount = customerData.SellAmount ?? 0;
                        }
                        if (customerData.RegNo != null)
                        {
                            plot.RegNo = customerData.RegNo;
                        }
                        if (customerData.RegDate != null)
                        {
                            plot.RegDate = customerData.RegDate;
                        }
                        if (customerData.AllotmentLtDt != null)
                        {
                            plot.AllotmentLtDt = customerData.AllotmentLtDt;
                        }
                        if (customerData.TitleClearFrom != null)
                        {
                            plot.TitleClearFrom = customerData.TitleClearFrom;
                        }
                        if (customerData.TitleClearDt != null)
                        {
                            plot.TitleClearDt = customerData.TitleClearDt;
                        }
                        plot.Bank = customerData.Bank;
                    }
                    var intSave = ctx.SaveChanges();
                    return(intSave);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #5
0
 public int Delete(int Id)
 {
     using (var db = new AppDb())
     {
         var data = db.payment.FirstOrDefault(f => f.Id == Id);
         if (data != null)
         {
             db.Entry(data).State = System.Data.Entity.EntityState.Deleted;
             return(db.SaveChanges());
         }
         return(0);
     }
 }
Пример #6
0
 public int UpdatePass(user usr)
 {
     using (var db = new AppDb())
     {
         var checkuser = db.users.FirstOrDefault(f => f.Email == usr.Email);
         if (checkuser != null)
         {
             checkuser.Password = usr.Password;
             var rec = db.SaveChanges();
             return(rec);
         }
         throw new Exception("User not register yet, Please register user first!");
     }
 }
Пример #7
0
 public int Add(user usr)
 {
     using (var db = new AppDb())
     {
         var checkuser = db.users.FirstOrDefault(f => f.Email == usr.Email);
         if (checkuser != null)
         {
             throw new Exception("User already exists, Click on forgot password for regenerate your password!");
         }
         services.Common.PasswordCryptoService crypto = new services.Common.PasswordCryptoService();
         usr.Password = crypto.EncryptText(usr.Password);
         db.users.Add(usr);
         var rec = db.SaveChanges();
         return(rec);
     }
 }
Пример #8
0
 public int Edit(user usr)
 {
     using (var db = new AppDb())
     {
         var checkuser = db.users.FirstOrDefault(f => f.Id == usr.Id);
         if (checkuser == null)
         {
             throw new Exception("User not found!");
         }
         else
         {
             checkuser.Lastname  = usr.Lastname;
             checkuser.Firstname = usr.Firstname;
             checkuser.Role      = usr.Role;
             checkuser.Email     = usr.Email;
         }
         db.Entry(checkuser).State = System.Data.Entity.EntityState.Modified;
         var rec = db.SaveChanges();
         return(rec);
     }
 }
Пример #9
0
 public string AddPlots(List <plot> plots)
 {
     try
     {
         using (var db = new AppDb())
         {
             plots.ForEach(f =>
             {
                 f.SellAmount   = 10000;
                 f.Installments = 10;
             });
             db.plot.AddRange(plots);
             db.SaveChanges();
         }
         return(plots.Count + " plots records were added");
     }
     catch (Exception ex)
     {
         return(ex.ToString());
     }
 }
Пример #10
0
 public int AddItems(List <invoice_items> invoice_items)
 {
     try
     {
         using (var ctx = new AppDb())
         {
             int?InvoiceID = invoice_items.FirstOrDefault().InvoiceID;
             if (InvoiceID != null)
             {
                 List <invoice_items> invoItems = ctx.invoice_items.Where(w => w.InvoiceID == InvoiceID).ToList();
                 ctx.invoice_items.RemoveRange(invoItems);
             }
             ctx.invoice_items.AddRange(invoice_items);
             ctx.SaveChanges();
             return(1);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #11
0
 public int AddItems(List <quotation_items> quotation_itemsData)
 {
     try
     {
         using (var ctx = new AppDb())
         {
             int?QuotationID = quotation_itemsData.FirstOrDefault().QuotationID;
             if (QuotationID != null)
             {
                 List <quotation_items> quoteItems = ctx.quotation_items.Where(w => w.QuotationID == QuotationID).ToList();
                 ctx.quotation_items.RemoveRange(quoteItems);
             }
             ctx.quotation_items.AddRange(quotation_itemsData);
             ctx.SaveChanges();
             return(1);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #12
0
 public int Add(template templateData)
 {
     try
     {
         using (var ctx = new AppDb())
         {
             var obj = ctx.template.FirstOrDefault(f => f.Id == templateData.Id);
             if (obj != null)
             {
                 ctx.Entry(obj).CurrentValues.SetValues(templateData);
             }
             else
             {
                 ctx.template.Add(templateData);
             }
             return(ctx.SaveChanges());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #13
0
 public int Add(quotation quotationData)
 {
     try
     {
         using (var ctx = new AppDb())
         {
             var obj = ctx.quotation.FirstOrDefault(f => f.Id == quotationData.Id);
             if (obj != null)
             {
                 ctx.Entry(obj).CurrentValues.SetValues(quotationData);
             }
             else
             {
                 ctx.quotation.Add(quotationData);
             }
             ctx.SaveChanges();
             return(quotationData.Id);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }