public async Task <JsonResult> EditType(Guid id, Type type)
        {
            if (id != type.Id)
            {
                return(Json(null));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var user = await _userManager.GetUserAsync(User);

                    var userRoles = await _userManager.GetRolesAsync(user);

                    await _typeService.UpdateDefault(userRoles, type);
                }
                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }
                return(Json(null));
            }
            return(Json(null));
        }
 public async Task <bool> Add(User user, Type type)
 {
     try
     {
         type.fk_UserId = user.Id;
         return(_typeRepository.Add(type));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemple #3
0
        public bool Delete(Type type)
        {
            try
            {
                _context.FinanceTypes.Update(type);
                _context.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
 public async Task <bool> AddDefault(IList <string> userRoles, Type type)
 {
     try
     {
         if (userRoles.Contains("Admin"))
         {
             type.fk_UserId = null;
             return(_typeRepository.Add(type));
         }
         return(false);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        public async Task <bool> Update(User user, Type type)
        {
            try
            {
                var realType = await GetById(user, type.Id);

                if (realType != null && realType.fk_UserId == user.Id)
                {
                    type.fk_UserId = user.Id;
                    return(_typeRepository.Update(type));
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #6
0
        private string MakeResult(PaymentModel model, string method, Type type, Payment payment)
        {
            var extraInput = type.ExtraInput != null?string.Join(',', type.ExtraInput) : "";

            var result = "<br class='created' />" + model.Date + "<br class='created' />" + model.Description + "<br class='created' />" + model.Amount;

            result += model.AdvancedAmount + "<br class='created' />";

            result += "<div class='created' id='divAdvancedAmount" + method + "PaymentFinance' style='display: none'>";

            if (type.EndTaxType == PaymentTaxType.Gross)
            {
                result += "<br class='created' />" + model.Amount_Gross + "<br class='created' />" + model.Amount_Net;
            }
            else if (type.EndTaxType == PaymentTaxType.Net)
            {
                result += "<br class='created' />" + model.Amount_Net + "<br class='created' />" + model.Amount_Gross;
            }

            if (extraInput.Contains(Convert.ToString((int)PaymentExtraInput.ExtraCost)))
            {
                result += model.ExtraCosts + model.AddExtraCost + "</div>";
            }
            else
            {
                result += "</div>";
            }

            result += "<br class='created' />" + model.Tax;

            if (extraInput.Contains(Convert.ToString((int)PaymentExtraInput.DetailedTax)))
            {
                result += model.AdvancedTaxList + "<br class='created' /> <div class='created' id='divAdvancedTax" + method + "PaymentFinance' style='display: none'> <br class='created' />" + model.TaxList + model.AddTax + "</div>";
            }

            if (extraInput.Contains(Convert.ToString((int)PaymentExtraInput.Category)))
            {
                result += "<br class='created' />" + model.Category;
            }

            result += "<br class='created' />" + model.Status + "<br class='created' />" + model.Invoice;

            return(result);
        }
Exemple #7
0
        public async Task <JsonResult> CreateType(Type type)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var user = await _userManager.GetUserAsync(User);

                    await _typeService.Add(user, type);
                }
                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }

                return(Json(null));
            }
            return(Json(null));
        }
        public async Task <bool> Delete(User user, Type type)
        {
            try
            {
                var realType = await GetById(user, type.Id);

                if (realType != null && realType.fk_UserId == user.Id)
                {
                    type.fk_UserId = user.Id;
                    type.Deleted   = true;
                    type.DeletedOn = DateTime.Today;
                    return(_typeRepository.Delete(type));
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public async Task <ICollection <Status> > GetByTypeId(User user, Type type)
        {
            try
            {
                var statuses = await GetAll(user);

                if (type.TransactionType == PaymentTransactionType.Both)
                {
                    return(statuses.ToList());
                }
                else
                {
                    return(statuses.Where(x => x.EndPoint == false || x.Id == type.fk_StatusId).ToList());
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public async Task <bool> UpdateDefault(IList <string> userRoles, Type type)
        {
            try
            {
                if (userRoles.Contains("Admin"))
                {
                    var realTypes = await GetDefault();

                    var realType = realTypes.Where(x => x.Id == type.Id).FirstOrDefault();
                    if (realType != null && realType.fk_UserId == null)
                    {
                        type.fk_UserId = null;
                        return(_typeRepository.Update(type));
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw;
            }
        }