예제 #1
0
        public IHttpActionResult GetExpensesEntry(int RecordID)
        {
            try
            {
                ExpensesEntry expensesEntry = new ExpensesEntry();
                using (UnitOfWork uow = new UnitOfWork())
                {
                    expensesEntry = uow.ExpensesEntryRepository.Get(x => x.RecordID == RecordID && x.FarmID == FARMID);

                    expensesEntry = expensesEntry == null ? new ExpensesEntry {
                        RecordID = -1
                    } : expensesEntry;
                    var lstExpensesMaster = uow.ExpensesMasterRepository.GetAll(x => x.FarmID == FARMID && x.IsDeleted != false).ToList();

                    return(Ok(new
                    {
                        expensesEntry,
                        lstExpensesMaster
                    }));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
 public void Delete(ExpensesEntry entity)
 {
     try
     {
         entities.ExpensesEntrys.Remove(entity);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #3
0
 public void Add(ExpensesEntry entity)
 {
     try
     {
         entities.ExpensesEntrys.Add(entity);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #4
0
 public void Attach(ExpensesEntry entity)
 {
     try
     {
         entities.ExpensesEntrys.Attach(entity);
         entities.Entry(entity).State = System.Data.Entity.EntityState.Modified;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #5
0
        public IHttpActionResult Save(ExpensesEntry expensesEntry)
        {
            try
            {
                ExpensesEntry expensesEntrydtl = new ExpensesEntry();
                using (UnitOfWork uow = new UnitOfWork())
                {
                    if (expensesEntry.RecordID == -1)
                    {
                        expensesEntrydtl = expensesEntry;

                        expensesEntrydtl.CreatedBy = "ADMIN";
                        expensesEntrydtl.CreatedOn = DateTime.UtcNow;
                    }
                    else
                    {
                        expensesEntrydtl = uow.ExpensesEntryRepository.Get(x => x.RecordID == expensesEntry.RecordID);

                        expensesEntrydtl.ExpensesCode  = expensesEntry.ExpensesCode;
                        expensesEntrydtl.VendorName    = expensesEntry.VendorName;
                        expensesEntrydtl.VendorAddress = expensesEntry.VendorAddress;
                        expensesEntrydtl.Amount        = expensesEntry.Amount;
                        expensesEntrydtl.Remarks       = expensesEntry.Remarks;
                        expensesEntrydtl.IsDeleted     = expensesEntry.IsDeleted;

                        expensesEntrydtl.ModifiedBy = "ADMIN";
                        expensesEntrydtl.ModifiedOn = DateTime.UtcNow;
                    }
                    expensesEntrydtl.FarmID = FARMID;

                    uow.ExpensesEntryRepository.Save(expensesEntrydtl);
                    uow.SaveChanges();

                    return(Ok(new
                    {
                    }));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #6
0
        public void Save(ExpensesEntry entity)
        {
            try
            {
                ExpensesEntry expensesEntry = entities.ExpensesEntrys
                                              .Where(x => x.FarmID == entity.FarmID && x.RecordID == entity.RecordID).FirstOrDefault();

                if (expensesEntry != null)
                {
                    entities.Entry(expensesEntry).State = EntityState.Modified;
                }
                else
                {
                    Add(entity);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }