Exemple #1
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Edit(int id, [Bind("PaymentMediaId,PaymentMediaDescription")] PaymentMedia paymentMedia)
        {
            if (id != paymentMedia.PaymentMediaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(paymentMedia);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaymentMediaExists(paymentMedia.PaymentMediaId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(paymentMedia));
        }
        public async Task <IActionResult> Edit(int id, [Bind("CashSubcategoryId,CashSubcategoryDescription,CashCategoryId")] CashSubcategory cashSubcategory)
        {
            if (id != cashSubcategory.CashSubcategoryId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cashSubcategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CashSubcategoryExists(cashSubcategory.CashSubcategoryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CashCategoryId"] = new SelectList(_context.CashCategory, "CashCategoryId", "CashCategoryDescription", cashSubcategory.CashCategoryId);
            return(View(cashSubcategory));
        }
Exemple #3
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Edit(int id, [Bind("ResourceId,FullName,BirthDate,Email,Address,Phones,RoleId")] Resource resource)
        {
            if (id != resource.ResourceId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(resource);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ResourceExists(resource.ResourceId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoleId"] = new SelectList(_context.Role, "RoleId", "RoleDescription", resource.RoleId);
            return(View(resource));
        }
        public async Task <IActionResult> Edit(int id, [Bind("WorkdayId,ResourceId,WorkingDate,QuantityOne,QuantityTwo")] Workday workday)
        {
            if (id != workday.WorkdayId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(workday);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WorkdayExists(workday.WorkdayId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ResourceId"] = new SelectList(_context.Resource, "ResourceId", "FullName", workday.ResourceId);
            return(View(workday));
        }
Exemple #5
0
        public async Task <IActionResult> Edit(int id, [Bind("CashMovementTypeId,CashMovementTypeDescription")] CashMovementType cashMovementType)
        {
            if (id != cashMovementType.CashMovementTypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cashMovementType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CashMovementTypeExists(cashMovementType.CashMovementTypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cashMovementType));
        }
        public async Task <IActionResult> Edit(int id, [Bind("NotificationId,Everyone,Send,To,Message")] Notification notification)
        {
            if (id != notification.NotificationId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(notification);

                    SendNotification(notification);

                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NotificationExists(notification.NotificationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(notification));
        }
Exemple #7
0
 //[ValidateAntiForgeryToken]
 public async Task <IActionResult> Edit(int id, [Bind("CashCategoryId,CashCategoryDescription")] CashCategory cashCategory)
 {
     if (id != cashCategory.CashCategoryId)
     {
         return(NotFound());
     }
     if (cashCategory.CashCategoryDescription.Equals("Movimiento de pago"))
     {
         ModelState.AddModelError("DataError", "No se puede crear entidad con esa descripción.");
     }
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(cashCategory);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!CashCategoryExists(cashCategory.CashCategoryId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(cashCategory));
 }
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Edit(int id, [Bind("AutomaticProcessId,AutomaticProcessDesctipion,NextProcessDate")] AutomaticProcess automaticProcess)
        {
            if (id != automaticProcess.AutomaticProcessId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(automaticProcess);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AutomaticProcessExists(automaticProcess.AutomaticProcessId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(automaticProcess));
        }
Exemple #9
0
        public async Task <IActionResult> Edit(int id, [Bind("RoleId,RoleDescription")] Role role)
        {
            if (id != role.RoleId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(role);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RoleExists(role.RoleId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(role));
        }
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Edit(int id, [Bind("MedicalEmergencyId,MedicalEmergencyDescription")] MedicalEmergency medicalEmergency)
        {
            if (id != medicalEmergency.MedicalEmergencyId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(medicalEmergency);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MedicalEmergencyExists(medicalEmergency.MedicalEmergencyId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(medicalEmergency));
        }
Exemple #11
0
        public async Task <IActionResult> Edit(int id, [FromForm] User user) //[Bind("UserId,Token,FullName,BirthDate,DocumentNumber,Email,Address,Phones,SignInDate,Commentaries")] User user)
        {
            if (id != user.UserId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.UserId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MedicalEmergencyId"] = new SelectList(_context.Set <MedicalEmergency>(), "MedicalEmergencyId", "MedicalEmergencyDescription", user.MedicalEmergencyId);
            return(View(user));
        }
Exemple #12
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Edit(int id, [Bind("UserReportId,SignInDateFrom,SignInDateTo,AssitanceFrom,AssitanceTo,AgeFrom,AgeTo,AssitanceCountFrom,AssitanceCountTo,PayDateFrom,PayDateTo,MovementTypeId,PaymentMediaId")] UserReport userReport)
        {
            if (id != userReport.UserReportId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userReport);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserReportExists(userReport.UserReportId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MovementTypeId"] = new SelectList(_context.MovementType, "MovementTypeId", "Description", userReport.MovementTypeId);
            ViewData["PaymentMediaId"] = new SelectList(_context.PaymentMedia, "PaymentMediaId", "PaymentMediaDescription", userReport.PaymentMediaId);
            return(View(userReport));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ScheduleMassivelyId,DisciplineId,StartTime,EndTime,ResourceId,Places,DataFormatStartString,DataFormatEndString")] ScheduleMassively scheduleMassively)
        {
            if (id != scheduleMassively.ScheduleMassivelyId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(scheduleMassively);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ScheduleMassivelyExists(scheduleMassively.ScheduleMassivelyId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DisciplineId"] = new SelectList(_context.Discipline, "DisciplineId", "DisciplineDescription", scheduleMassively.DisciplineId);
            ViewData["ResourceId"]   = new SelectList(_context.Resource, "ResourceId", "Email", scheduleMassively.ResourceId);
            return(View(scheduleMassively));
        }
        public async Task <IActionResult> Edit(int id, [Bind("SupplierId,SupplierDescription")] Supplier supplier)
        {
            if (id != supplier.SupplierId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(supplier);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SupplierExists(supplier.SupplierId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(supplier));
        }
Exemple #15
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Edit(int id, [Bind("CashMovementId,CashMovementDate,CashMovementDetails,Amount,CashMovementTypeId,CashCategoryId,SupplierId,CashSubcategoryId,PaymentMediaId")] CashMovement cashMovement)
        {
            if (id != cashMovement.CashMovementId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cashMovement);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CashMovementExists(cashMovement.CashMovementId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CashCategoryId"]     = new SelectList(_context.CashCategory, "CashCategoryId", "CashCategoryDescription", cashMovement.CashCategoryId);
            ViewData["CashSubcategoryId"]  = new SelectList(_context.CashSubcategory, "CashSubcategoryId", "CashSubcategoryDescription", cashMovement.CashSubcategoryId);
            ViewData["CashMovementTypeId"] = new SelectList(_context.Set <CashMovementType>(), "CashMovementTypeId", "CashMovementTypeDescription", cashMovement.CashMovementTypeId);
            ViewData["SupplierId"]         = new SelectList(_context.Set <Supplier>(), "SupplierId", "SupplierDescription", cashMovement.SupplierId);
            ViewData["PaymentMediaId"]     = new SelectList(_context.Set <PaymentMedia>(), "PaymentMediaId", "PaymentMediaDescription", cashMovement.PaymentMediaId);
            return(View(cashMovement));
        }
Exemple #16
0
        //[ValidateAntiForgeryToken]
        public IActionResult Edit(int id, [Bind("PaymentId,PaymentDate,MovementTypeId,QuantityMovmentType,Amount,PaymentMediaId,UserId,LimitUsableDate")] Payment payment)
        {
            if (id != payment.PaymentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (_paymentLogic.ProcessPayment(payment,
                                                     _context.User.Where(u => u.UserId == payment.UserId).First().FullName,
                                                     _context.User.Where(u => u.UserId == payment.UserId).First().Email))
                    {
                        var cashMovsPayment = _context.CashMovement.Where(c => c.PaymentId == payment.PaymentId);
                        if (cashMovsPayment.Count() > 0)
                        {
                            CashMovement cashMov = cashMovsPayment.FirstOrDefault();
                            cashMov.Amount           = payment.Amount;
                            cashMov.CashMovementDate = payment.PaymentDate;
                            cashMov.PaymentMediaId   = payment.PaymentMediaId;

                            _context.Update(cashMov);
                        }
                        _context.SaveChanges();
                        return(RedirectToAction(nameof(Index)));
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaymentExists(payment.PaymentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            ViewData["MovementTypeId"] = new SelectList(_context.MovementType, "MovementTypeId", "Description", payment.MovementTypeId);
            ViewData["PaymentMediaId"] = new SelectList(_context.Set <PaymentMedia>(), "PaymentMediaId", "PaymentMediaDescription", payment.PaymentMediaId);
            ViewData["UserId"]         = new SelectList(_context.User.Where(u => u.UserId == payment.UserId), "UserId", "FullName", payment.UserId);
            return(View(payment));
        }
        public void NotifyUsers()
        {
            try
            {
                AutomaticProcess automaticSendMailProcess = _context.AutomaticProcess.
                                                            Where(x => x.AutomaticProcessId == int.Parse(_appSettings.Value.PaymentNotificationProcessId)).FirstOrDefault();
                if (automaticSendMailProcess != null && automaticSendMailProcess.NextProcessDate <= _timeZone.GetCurrentDateTime(DateTime.Now).Date)
                {
                    string notifyByDate = _appSettings.Value.PaymentNotificationByDate;
                    if (bool.Parse(notifyByDate))
                    {
                        NotifyByDate();
                    }

                    string notifyByExp = _appSettings.Value.PaymentNotificationByExpiration;
                    if (bool.Parse(notifyByExp))
                    {
                        NotifyByExpiration();
                    }

                    automaticSendMailProcess.NextProcessDate = _timeZone.GetCurrentDateTime(DateTime.Now).Date.AddDays(int.Parse(_appSettings.Value.PaymentNotificationProcessAddDays));

                    _context.Update(automaticSendMailProcess);
                    _context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                var messageError = ex.Message;
                _logger.LogError("Error Processing Payment. Detail: " + messageError);
                if (ex.InnerException != null)
                {
                    _logger.LogError("Error Processing Payment. Detail: " + ex.InnerException.Message);
                }
            }
        }
        public bool ProcessPayment(Payment payment, string userName, string userEmail)
        {
            var isEdit = false;

            if (payment.PaymentId > 0)
            {
                isEdit = true;
            }

            try
            {
                if (isEdit)
                {
                    _context.Update(payment);
                    _context.SaveChanges();
                }
                else
                {
                    _context.Add(payment);
                    _context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                var messageError = ex.Message;
                _logger.LogError("Error Processing Payment. Detail: " + messageError);
                if (ex.InnerException != null)
                {
                    _logger.LogError("Error Processing Payment. Detail: " + ex.InnerException.Message);
                }
                return(false);
            }

            try
            {
                var bodyData = new System.Collections.Generic.Dictionary <string, string>
                {
                    { "UserName", userName },
                    { "Title", "Notificación de pago realizado." },
                    { "amount", payment.Amount.ToString() },
                    { "paymentDate", payment.PaymentDate.ToShortDateString() },
                    { "limitDate", payment.LimitUsableDate.ToShortDateString() },
                    { "quantity", payment.QuantityMovmentType.ToString() }
                };

                switch (payment.MovementTypeId)
                {
                    #region Mensual
                case (int)PaymentTypeEnum.Monthly:
                    if (payment.QuantityMovmentType > 1)
                    {
                        bodyData.Add("type", "meses");
                    }
                    else
                    {
                        bodyData.Add("type", "mes");
                    }
                    break;

                    #endregion
                    #region Por asistencias
                case (int)PaymentTypeEnum.ByAssistances:
                    if (payment.QuantityMovmentType > 1)
                    {
                        bodyData.Add("type", "asistencias");
                    }
                    else
                    {
                        bodyData.Add("type", "asistencia");
                    }
                    break;
                    #endregion
                }

                if (isEdit)
                {
                    bodyData.Add("action", "editado");
                    bodyData.Add("paymentId", payment.PaymentId + " ");
                }
                else
                {
                    bodyData.Add("action", "registrado");
                    bodyData.Add("paymentId", string.Empty);
                }

                _sendEmail.SendEmail(bodyData,
                                     "PaymentTemplate",
                                     "Notificación de pago realizado",
                                     new System.Collections.Generic.List <string>()
                {
                    userEmail
                }
                                     );
            }
            catch (Exception ex)
            {
                var messageError = ex.Message;
                _logger.LogError("Error Sending email. Detail: " + messageError);
                if (ex.InnerException != null)
                {
                    _logger.LogError("Error Sending email. Detail: " + ex.InnerException.Message);
                }
            }

            return(true);
        }