예제 #1
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;
            }
        }
예제 #2
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);
     }
 }
예제 #3
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);
     }
 }
예제 #4
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;
     }
 }
예제 #5
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;
     }
 }