Esempio n. 1
0
        public IList <DailyIncomeObject> GetAllDailyIncomeSheet()
        {
            try
            {
                List <DailyIncomeObject> dailyIncomeList = new List <DailyIncomeObject>();
                foreach (DailyIncome source in (IEnumerable <DailyIncome>)dailyIncomeRepo.GetAll())
                {
                    DailyIncomeObject incomeObject = _Mapper.Map <DailyIncome, DailyIncomeObject>(source);
                    dailyIncomeList.Add(incomeObject);
                }

                return((IList <DailyIncomeObject>)dailyIncomeList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
 public async Task <IActionResult> Put(DailyIncomeObject obj)
 {
     try
     {
         if (obj.Id != Guid.Empty)
         {
             if (await _Logic.UpdateDailyIncome(obj))
             {
                 return(Ok());
             }
             return(BadRequest());
         }
         return(BadRequest());
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 3
0
        public Task <Guid> CreateDailyIncome(DailyIncomeObject obj)
        {
            return(Task.Run(() =>
            {
                try
                {
                    if (obj.Id == Guid.Empty)
                    {
                        var dataObj = new MapperConfiguration(doj =>
                        {
                            doj.CreateMap <DailyIncomeObject, DailyIncome>();
                        });

                        IMapper iMapper = dataObj.CreateMapper();

                        var source = new DailyIncome();

                        source.Id = IdentityGenerator.NewSequentialGuid();
                        source.AmountMade = obj.AmountMade;
                        source.Balance = obj.Balance;
                        source.CompulsorySavings = obj.CompulsorySavings;
                        source.PercentageProfit = obj.PercentageProfit;
                        source.Profit = obj.Profit;
                        source.DaillyAllowance = obj.DaillyAllowance;
                        source.EntryDate = obj.EntryDate;
                        source.Expenses = obj.Expenses;

                        dailyIncomeRepo.Add(source);
                        dailyIncomeRepo.UnitofWork.Commit();

                        return source.Id;
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }));
        }
Esempio n. 4
0
 public Task <bool> RemoveDailyIncome(DailyIncomeObject obj)
 {
     return(Task.Run(() =>
     {
         try
         {
             if (obj.Id != Guid.Empty)
             {
                 dailyIncomeRepo.Delete(obj.Id);
             }
             dailyIncomeRepo.UnitofWork.Commit();
             return true;
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }));
 }
Esempio n. 5
0
        public async Task <ActionResult <DailyIncome> > Delete(DailyIncomeObject obj)
        {
            try
            {
                if (obj.Id != Guid.Empty)
                {
                    if (await _Logic.RemoveDailyIncome(obj))
                    {
                        return(Ok());
                    }
                    return(BadRequest());
                }

                return(BadRequest());
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 6
0
        public async Task <ActionResult <DailyIncome> > Post(DailyIncomeObject obj)
        {
            try
            {
                if (obj.Id == Guid.Empty)
                {
                    obj.Id = await _Logic.CreateDailyIncome(obj);

                    if (obj.Id != Guid.Empty)
                    {
                        return(Ok(obj.Id));
                    }
                    return(BadRequest());
                }
                return(BadRequest());
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 7
0
        public async Task <IHttpActionResult> Post(DailyIncomeObject obj)
        {
            try
            {
                if (obj.Id == Guid.Empty)
                {
                    obj.Id = await _Service.CreateDailyIncome(obj);

                    if (obj.Id != Guid.Empty)
                    {
                        return(Ok(obj.Id));
                    }
                    return(BadRequest());
                }
                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Esempio n. 8
0
        public Task <bool> UpdateDailyIncome(DailyIncomeObject obj)
        {
            return(Task.Run(() =>
            {
                try
                {
                    DailyIncome entity = _Mapper.Map <DailyIncomeObject, DailyIncome>(obj);

                    if (obj.Id != Guid.Empty)
                    {
                        dailyIncomeRepo.Update(entity);
                    }
                    dailyIncomeRepo.UnitofWork.Commit();

                    return true;
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException(ex.Message);
                }
            }));
        }