Exemplo n.º 1
0
        public async Task <IActionResult> ChangeStatus([FromBody] ChangeStatusViewModel changeStatusViewModel)
        {
            try
            {
                var updatedCourse = await courseService.GetById(changeStatusViewModel.CourseId);

                if (updatedCourse != null)
                {
                    updatedCourse.StatusId = changeStatusViewModel.StatusId;

                    await courseService.Update(updatedCourse);

                    return(Ok(new
                    {
                        Results = updatedCourse
                    }));
                }
                else
                {
                    return(BadRequest(new
                    {
                        Errors = new { Code = "InvalidInputParameters", Description = "Invalid Input Parameters!" }
                    }));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"ErrorMesages: {e}");

                return(BadRequest(new
                {
                    Errors = new { Code = "InvalidId", Description = "Invalid Id!" }
                }));
            }
        }
        public async Task ThenNewStopDateIsApplied()
        {
            var updateDate = DateTime.Today;

            MockMediator.Setup(x => x.SendAsync(It.IsAny <GetApprenticeshipQueryRequest>())).Returns(Task.FromResult(new GetApprenticeshipQueryResponse {
                Apprenticeship = new Apprenticeship {
                    PaymentStatus = PaymentStatus.Withdrawn
                }
            }));

            MockMediator.Setup(x => x.SendAsync(It.IsAny <UpdateApprenticeshipStatusCommand>())).Callback <IAsyncRequest <Unit> >(u =>
            {
                var command = u as UpdateApprenticeshipStatusCommand;
                Assert.AreEqual(updateDate, command.DateOfChange);
                Assert.AreEqual((int)ChangeStatusType.Stop, (int)command.ChangeType);
            }).Returns(Task.FromResult(new Unit()));

            const string accountId    = "accountid";
            const string apprenticeId = "apprenticeId";

            var updateDateModel = new DateTimeViewModel {
                Day = updateDate.Day, Month = updateDate.Month, Year = updateDate.Year
            };

            var newStopDate = new ChangeStatusViewModel
            {
                ChangeType       = ChangeStatusType.Stop,
                DateOfChange     = updateDateModel,
                WhenToMakeChange = WhenToMakeChangeOptions.SpecificDate,
                ChangeConfirmed  = true
            };

            await Orchestrator.UpdateStatus(accountId, apprenticeId, newStopDate, string.Empty, string.Empty, string.Empty);
        }
Exemplo n.º 3
0
        public IActionResult ChangeStatusRejected([FromBody] ChangeStatusViewModel changeStatusViewModel)
        {
            try
            {
                var             centerId  = int.Parse(Request.Cookies["CenterId"]);
                var             cnp       = changeStatusViewModel.CNP;
                var             date      = changeStatusViewModel.Date;
                List <BloodBag> bloodBags = employeeService.GetBloodBags(centerId);
                foreach (BloodBag b in bloodBags)
                {
                    if (b.Date.ToString().Equals(date) && b.Analysis.Donor.CNP.Equals(cnp))
                    {
                        employeeService.ChangeStatusReject(b);
                        break;
                    }
                }

                //return Ok("Status updated");
                var bagsStock     = employeeService.GetBloodBags(centerId);
                var thromboStock  = employeeService.GetThrombocytesStock(centerId);
                var redCellsStock = employeeService.GetRedBloodCellsStock(centerId);
                var plasmaStock   = employeeService.GetPlasmaStock(centerId);

                return(Ok(CreateFullStock(bagsStock, thromboStock, redCellsStock, plasmaStock)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
 public void Initialize()
 {
     jiraServiceMock       = new Mock <IJiraService>();
     navigationServiceMock = new Mock <INavigationService>();
     dialogServiceMock     = new Mock <IDialogService>();
     changeStatusViewModel = new ChangeStatusViewModel(navigationServiceMock.Object, dialogServiceMock.Object, jiraServiceMock.Object);
 }
Exemplo n.º 5
0
        public async Task <ResponseServiceDTO> ChangeStatus(ChangeStatusViewModel viewModel)
        {
            try
            {
                var userExist = await _userRepository.GetByEmail(viewModel.Email);

                if (userExist == null)
                {
                    throw new DomainException("This Email don't is registered"); //Warning here
                }
                if (viewModel != null && viewModel.Active.Equals(userExist.Active))
                {
                    return(new ResponseServiceDTO(200, _mapper.Map <UserSimpleDTO>(userExist), "Success! Your user already had this status.", true));
                }

                var response = await _userRepository.ChangeStatus(userExist, viewModel.Active);

                if (response.Success)
                {
                    return(new ResponseServiceDTO(200, _mapper.Map <UserSimpleDTO>(userExist), "Success! Your user has been updated (Status only).", true));
                }
                return(new ResponseServiceDTO(500, viewModel, $"An error ocurred: {response.Message}", false));
            }
            catch (PomoControlException ex)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 6
0
        public void ChangeTaskStatus(ChangeStatusViewModel changeStatusViewModel)
        {
            TaskRepository    repo  = new TaskRepository(_connectionString);
            AccountRepository aRepo = new AccountRepository(_connectionString);
            User user = aRepo.GetByEmail(User.Identity.Name);

            repo.ChangeStatus(changeStatusViewModel.TaskId, changeStatusViewModel.Status, user);
        }
Exemplo n.º 7
0
        public IActionResult ChangeStatus(int vacationId)
        {
            var model = new ChangeStatusViewModel {
                VacationId = vacationId, Role = "Administration"
            };

            return(this.PartialView("/Areas/Manager/Views/Vacations/_ChangeStatusPartial.cshtml", model));
        }
Exemplo n.º 8
0
        public void ChangeStatusIfDataIsNullTest()
        {
            ChangeStatusViewModel data = null;

            var result = _orderController.ChangeStatus(data);

            Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult));
        }
        public IActionResult ChangeStatus(int vacationId)
        {
            var model = new ChangeStatusViewModel {
                VacationId = vacationId, Role = "Manager"
            };

            return(this.PartialView("_ChangeStatusPartial", model));
        }
Exemplo n.º 10
0
        public ActionResult ChangeStatus(int orderId)
        {
            var model = new ChangeStatusViewModel();
            var order = orderProvider.GetOrder(orderId);

            model.CurrentStatusId = order.OrderStatusId;
            model.CurrentStatus   = GetOrderStatusName(model.CurrentStatusId);

            return(PartialView(model));
        }
Exemplo n.º 11
0
        public async Task Put(Guid orderId, [FromBody] ChangeStatusViewModel orderStatus)
        {
            bool validId = Guid.TryParse(User.FindFirst("sub")?.Value, out Guid storeId);

            if (!validId)
            {
                throw new Exception("Invalid user id");
            }

            await _applicationService.ChangeOrderStatus(storeId, orderId, orderStatus);
        }
Exemplo n.º 12
0
        public void SendEmail(string formData, ChangeStatusViewModel viewModel, UrlHelper url, string scheme)
        {
            try
            {
                var emailTemplateNode = "//body/emailNotificationTemplates/emailNotificationTemplate";

                var xmlForm = FormXmlService.LoadXmlForm(viewModel.FormId);
                FormXmlService.XmlForm = xmlForm;
                FormXmlService.Url     = url;
                FormXmlService.Scheme  = scheme;

                var    senderMail = "*****@*****.**";
                var    receivers  = FormXmlService.ParseFields(formData, xmlForm.SelectSingleNode(emailTemplateNode + "[templateId='" + viewModel.SendEmailNotification + "']/recipient").InnerXml).Split(',');
                var    smtpserver = String.Format("{0}", Config.Value.SmtpServer);
                string objectMail = FormXmlService.ParseFields(formData, xmlForm.SelectSingleNode(emailTemplateNode + "[templateId='" + viewModel.SendEmailNotification + "']/subject").InnerXml);
                string bodyMail   = FormXmlService.ParseFields(formData, xmlForm.SelectSingleNode(emailTemplateNode + "[templateId='" + viewModel.SendEmailNotification + "']/body").InnerXml, viewModel.RequestFormId, viewModel.Comment);
                int    numPort    = Int32.Parse(String.Format("{0}", Config.Value.SmtpPort));
                //int i = 0;

                //var ws = new verifyPassword();
                //var receiverEmail = ws.GetUserDataByKeyLDAP("vvergara1", "mail");

                //var receiverMail = LdapIdentify.
                var mail = new MailMessage(senderMail, receivers[0], objectMail, bodyMail);
                if (receivers.Count() > 1)
                {
                    foreach (var receiver in receivers)
                    {
                        mail.To.Add(receiver);
                    }
                }

                SmtpClient client = new SmtpClient(smtpserver);
                client.Port = numPort;

                // Send the mail
                Task.Run(() => {
                    try
                    {
                        client.Send(mail);
                    }
                    catch (Exception ex)
                    {
                        Logger.Info("An error has occurred sending the notification email: " + ex.Message);
                    }
                });
            }
            catch (Exception ex)
            {
                Logger.Info("An error has occurred: " + ex.Message);
            }

            Logger.Info("Email sent successfully.");
        }
Exemplo n.º 13
0
        public void ChangeStatusIfDataIsNotNullTest()
        {
            var data = new ChangeStatusViewModel()
            {
                Id       = 2,
                StatusId = 2
            };

            var result = _orderController.ChangeStatus(data) as RedirectToRouteResult;

            Assert.AreEqual("Index", result.RouteValues["action"]);
        }
Exemplo n.º 14
0
 public IActionResult Put([FromBody] ChangeStatusViewModel model)
 {
     if (ModelState.IsValid)
     {
         var response = repo.SetAdvertStatus(model);
         if (response)
         {
             return(Ok());
         }
     }
     return(BadRequest());
 }
        public async Task <IActionResult> ChangeStatus(ChangeStatusViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                var returnModel = new ChangeStatusViewModel {
                    VacationId = model.VacationId
                };
                return(this.PartialView("_ChangeStatusPartial", returnModel));
            }

            await this.vocationService.ChangeStatusAsync(model.VacationId, model.Status);

            return(this.RedirectToAction("Employee"));
        }
Exemplo n.º 16
0
        public async Task <IActionResult> ChangeStatus(ChangeStatusViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                var returnModel = new ChangeStatusViewModel {
                    VacationId = model.VacationId
                };
                return(this.PartialView("/Areas/Manager/Views/Vacations/_ChangeStatusPartial.cshtml", returnModel));
            }

            await this.vacationsService.ChangeStatusAsync(model.VacationId, model.Status);

            return(this.RedirectToAction("Index"));
        }
Exemplo n.º 17
0
        public IHttpActionResult ChangeStatus(ChangeStatusViewModel data)
        {
            if (data != null)
            {
                var orderInDb = _uow.GetRepository <Order>().Get(r => r.Id == data.Id);
                if (data.StatusId != 0)
                {
                    orderInDb.StatusId = data.StatusId;
                }
                _uow.SaveChanges();

                return(Ok());
            }
            return(NotFound());
        }
Exemplo n.º 18
0
        public bool SetAdvertStatus(ChangeStatusViewModel model)
        {
            var res = false;

            using (IDbConnection db = new SqlConnection(Global.Connection))
            {
                res = db.Query <bool>("sp_ShowAdvert", new
                {
                    Prc_Id       = model.Id,
                    Cust_ID_Main = model.CustIdMain,
                    IsHid        = model.IsHid,
                },
                                      commandType: CommandType.StoredProcedure).First();
            }
            return(res);
        }
Exemplo n.º 19
0
        public async Task <IActionResult> ChangeStatus(ChangeStatusViewModel model)
        {
            var post = _context.Posts.FirstOrDefault(p => p.Id == model.PostId);

            if (post != null)
            {
                post.Status = model.Status;

                _context.Posts.Update(post);
                _context.SaveChanges();
            }

            //Post to Hub
            await _hubContext.Clients.All.SendAsync("ReceiveNotification", Guid.Parse("0bb8a75f-68ea-4d27-9c5f-81b8cdd9d000"), "Your post " + post.Title + " has been updated to " + post.Status);

            return(RedirectPermanent("~/manage/posts?columnId=" + model.ColumnId));
        }
Exemplo n.º 20
0
        public async Task <Order> UpdateOrderStatusAsync(Guid orderId, OrderStatus orderStatus)
        {
            var client = getHttpClient();
            var orderStatusViewModel = new ChangeStatusViewModel {
                OrderStatus = orderStatus
            };
            var orderSerialized = _serializerService.Serialize(orderStatusViewModel);
            var httpContent     = new StringContent(orderSerialized, Encoding.UTF8, "application/json");

            var result = await client.PutAsync(_baseUrl + "/" + orderId + "/status", httpContent);

            var serializedOrders = await result.Content.ReadAsStringAsync();

            var order = _serializerService.Deserialize <Order>(serializedOrders);

            return(order);
        }
Exemplo n.º 21
0
        public async Task <IActionResult> ChangeStatus(ChangeStatusViewModel model)
        {
            var booking = _context.Bookings.FirstOrDefault(p => p.Id == model.BookingId);

            if (booking != null)
            {
                booking.ReserveStatus = model.Status;

                _context.Bookings.Update(booking);
                _context.SaveChanges();
            }
            //Post to Hub
            await _hubContext.Clients.All.SendAsync("ReceiveNotification", booking.UserId, "Your booking " + booking.ShopServiceName + " has been updated to " + booking.ReserveStatus + " " + " date of " + booking.UpdatedAt);


            return(RedirectPermanent("~/shop/my-dashboard"));
        }
Exemplo n.º 22
0
        public IActionResult ChangeStatus(ChangeStatusViewModel model)
        {
            if (ModelState.IsValid)
            {
                User user = _context.FindUser(model.Id);

                if (user != null)
                {
                    bool result;
                    if (model.StatusName == "block")
                    {
                        if (model.IsForever == true)        //заблокировать навсегда
                        {
                            user.id_status = _context.FindStatus(model.StatusName).Id;
                            result         = _context.BlockUserForever(user.Id, user);
                        }
                        else                     //заблокировать до времени
                        {
                            user.id_status        = _context.FindStatus(model.StatusName).Id;
                            user.dateofbeginblock = DateTime.Now;
                            user.dateofendbock    = model.Dateofendblock;
                            result = _context.BlockUser(user.Id, user);
                        }
                    }
                    else          //notblock
                    {
                        user.id_status = _context.FindStatus(model.StatusName).Id;
                        result         = _context.UnblockUser(user.Id, user);
                    }

                    if (result)
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Ошибка");
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", "Ошибка");
            }
            return(View(model));
        }
Exemplo n.º 23
0
        public async Task <ActionResult> ChangeStatus(FormCollection form, ChangeStatusViewModel model)
        {
            try
            {
                orderProvider.SetStatusOrder(model.OrderId, model.NewStatusId, model.Notes, model.SendMail);
                if (model.SendMail)
                {
                    var order       = orderProvider.GetOrder(model.OrderId);
                    var orderStatus = orderStatusProvider.GetOrderStatus(model.NewStatusId);
                    var viewModel   = orderProvider.GetOrderMail(order);

                    if (orderStatus != null)
                    {
                        var config = new TemplateServiceConfiguration();
                        using (var service = RazorEngineService.Create(config))
                        {
                            var body = service.RunCompile(
                                orderStatus.EmailTemplate,
                                "OrderMail",
                                typeof(OrderMailViewModel),
                                new { viewModel });
                            await orderProvider.NotifyOrderStatusUpdate(
                                ConfigurationInstance[ConfigurationKeys.SmtpServer],
                                Convert.ToInt32(ConfigurationInstance[ConfigurationKeys.SmtpPort]),
                                Convert.ToBoolean(ConfigurationInstance[ConfigurationKeys.SmtpSsl]),
                                !Convert.ToBoolean(ConfigurationInstance[ConfigurationKeys.SmtpAuthentication]),
                                ConfigurationInstance[ConfigurationKeys.SmtpUserName],
                                ConfigurationInstance[ConfigurationKeys.SmtpPassword],
                                ConfigurationInstance[ConfigurationKeys.SystemSenderName],
                                ConfigurationInstance[ConfigurationKeys.SystemSenderAddress],
                                viewModel.CustomerMail,
                                body);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Response.StatusCode = 406;
                Response.Write(ex.Message);
                return(null);
            }

            return(Json(model));
        }
Exemplo n.º 24
0
        public IActionResult ChangeStatus(int id)
        {
            User user = _context.FindUser(Convert.ToInt32(id));

            if (user == null)
            {
                return(NotFound());
            }
            var userstatus  = _context.FindStatus(user.id_status);
            var allstatuses = _context.GetAllStatuses();

            ViewBag.AllStatuses = allstatuses;
            ChangeStatusViewModel model = new ChangeStatusViewModel {
                Id = user.Id, Email = user.Email, StatusName = userstatus.Name, Dateofendblock = DateTime.Now
            };

            return(View(model));
        }
Exemplo n.º 25
0
        public IActionResult ChangeStatus(string formData, ChangeStatusViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var urlScheme = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}{HttpContext.Request.Path}{HttpContext.Request.QueryString}";
                    FormRequestService.ChangeStatus(formData, viewModel, (UrlHelper)Url, urlScheme);
                }
                catch (Exception ex)
                {
                    Logger.Info("Ha ocurrido un error: " + ex.Message);
                    TempData[Constants.InfoKey] = "An error has happened in the saving process.";
                }
            }

            return(Json(new { RedirectTo = Url.Action("Index", "FormsBoard", new { idForm = viewModel.FormId, message = "Action executed successfully!" }) }));
        }
Exemplo n.º 26
0
        public void ChangeStatus(string formData, ChangeStatusViewModel viewModel, UrlHelper url, string scheme)
        {
            FormRequestViewModel.Id           = viewModel.RequestFormId;
            FormRequestViewModel.Reference    = viewModel.Reference;
            FormRequestViewModel.StatusId     = viewModel.NewStatus;
            FormRequestViewModel.FormId       = viewModel.FormId;
            FormRequestViewModel.JSonFormData = formData;
            FormRequestViewModel.CreatedBy    = viewModel.CreatedBy;

            FormXmlService.SetValue(ref formData, "statusId", viewModel.NewStatus);
            FormXmlService.SetValue(ref formData, "status", viewModel.NewStatusDisplayName);

            if (viewModel.RequestFormId == 0)
            {
                FormRequestViewModel.UserAssigned = UserUtil.DisplayUserName;
                FormXmlService.SetValue(ref formData, "userAssigned", UserUtil.DisplayUserName);
            }
            else
            {
                var xmlForm      = FormXmlService.LoadXmlForm(viewModel.FormId);
                var userAssigned = FormXmlService.ParseFields(formData, xmlForm.SelectSingleNode("//body/statuses/status[name='" + viewModel.NewStatus + "']/userAssigned").InnerXml);
                FormRequestViewModel.UserAssigned = userAssigned;
                FormXmlService.SetValue(ref formData, "userAssigned", userAssigned);
            }

            SaveFormRequest(FormRequestViewModel, formData, true);

            if (!string.IsNullOrEmpty(viewModel.Action))
            {
                var log = FormXmlService.ParseFields(formData, viewModel.Action);
                HistoryService.SaveHistory(FormRequestViewModel.Id, log, viewModel.Comment);
            }

            if (!string.IsNullOrEmpty(viewModel.SendEmailNotification))
            {
                var emailTemplates = viewModel.SendEmailNotification.Split(',');
                foreach (var template in emailTemplates)
                {
                    viewModel.SendEmailNotification = template;
                    EmailService.SendEmail(formData, viewModel, url, scheme);
                }
            }
        }
Exemplo n.º 27
0
 public IHttpActionResult ChangeCardStatus(ChangeStatusViewModel vm)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Invalid View Model"));
     }
     try
     {
         var cardDbEntity = _cardRepository.GetById(vm.Id);
         cardDbEntity.Status = vm.NewStatus;
         _cardRepository.Update(cardDbEntity);
         return(Ok());
     }
     catch (Exception e)
     {
         _logger.Error("Could not update card status with id: " + vm.Id + " . Exception Message: " + e.Message);
         return(BadRequest("Could not update card's status"));
     }
 }
        public async Task <IActionResult> ChangeStatus(int id)
        {
            ChangeStatusViewModel model = new ChangeStatusViewModel();

            //se gaseste biletul cautat
            var details = await _context.ReservedSeats.Where(x => x.Id == id).Include(x => x.seat).Include(x => x.TicketType).Include(x => x.seat.hall).Include(x => x.reservation.screening).Include(x => x.reservation.screening.movie).FirstOrDefaultAsync();

            if (details == null)
            {
                ViewBag.ErrorMessage = "Acest bilet a fost deja revendicat!!";
                return(View());
            }


            model.title    = details.reservation.screening.movie.title;
            model.date     = details.reservation.screening.date;
            model.hour     = details.reservation.screening.s_hour;
            model.hallname = details.seat.hall.name;
            model.row      = details.seat.row;
            model.seatNo   = (int)details.seat.seatNo;
            model.type     = details.TicketType.name;


            if (details.claimed == true)
            {
                ViewBag.ErrorMessage = "Acest bilet a fost deja revendicat!!";
            }
            else
            {
                var ticket = await _context.ReservedSeats.FindAsync(id);

                ticket.claimed = true;
                _context.ReservedSeats.Update(ticket);
                await _context.SaveChangesAsync();

                ViewBag.SuccesMessage = "Biletul a fost revendicat cu succes!!";
            }


            return(View(model));
        }
Exemplo n.º 29
0
        public async Task <ActionResult> ChangeStatus(ChangeStatusViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(model));
            }

            var loggedUserId = this.User.Identity.GetUserId();

            Data.Users.Find(loggedUserId).Status = model.Status;
            Data.SaveChanges();

            var user = await this.UserManager.FindByIdAsync(this.User.Identity.GetUserId());

            if (user != null)
            {
                await this.SignInManager.SignInAsync(user, false, false);
            }

            return(this.RedirectToAction("Index"));
        }
Exemplo n.º 30
0
        public IActionResult SeparateBloodBag([FromBody] ChangeStatusViewModel changeStatusViewModel)
        {
            try
            {
                var             centerId  = int.Parse(Request.Cookies["CenterId"]);
                var             cnp       = changeStatusViewModel.CNP;
                var             date      = changeStatusViewModel.Date;
                List <BloodBag> bloodBags = employeeService.GetBloodBags(centerId);
                foreach (BloodBag b in bloodBags)
                {
                    if (b.Date.ToString().Equals(date) && b.Analysis.Donor.CNP.Equals(cnp))
                    {
                        var thrombocyte  = MapperBloodBag.ToThrombocyte(b);
                        var redBloodCell = MapperBloodBag.ToRedBloodCell(b);
                        var plasma       = MapperBloodBag.ToPlasma(b);
                        employeeService.SeparateBloodBag(b, thrombocyte, plasma, redBloodCell);
                        //List<BloodBag> bbList = new List<BloodBag> { b };
                        //List<Thrombocyte> tList = new List<Thrombocyte> { thrombocyte };
                        //List<RedBloodCell> rbcList = new List<RedBloodCell> { redBloodCell };
                        //List<Plasma> pList = new List<Plasma> { plasma };
                        //return Ok(CreateFullStock(bbList,tList,rbcList,pList));
                        var bagsStock     = employeeService.GetBloodBags(centerId);
                        var thromboStock  = employeeService.GetThrombocytesStock(centerId);
                        var redCellsStock = employeeService.GetRedBloodCellsStock(centerId);
                        var plasmaStock   = employeeService.GetPlasmaStock(centerId);

                        return(Ok(CreateFullStock(bagsStock, thromboStock, redCellsStock, plasmaStock)));
                    }
                }
                List <BloodStockViewModel> finalStock = new List <BloodStockViewModel>();

                return(Ok(finalStock));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }