public ActionResult CreateTicket(TicketCreateModel model) { if (model.Content == null) { TempData["danger"] = "Error"; return(RedirectToAction("Index", "Ticket")); } var ticketId = Guid.NewGuid(); var ticket = new Ticket { Id = ticketId, IsClosed = false, Title = model.Title, Content = model.Content, FK_User = Guid.Parse(User.Identity.Name) }; _db.Tickets.Add(ticket); _db.SaveChanges(); return(RedirectToAction("View", new { id = ticketId })); }
public ActionResult Edit(int id) { TicketBiz ticketbiz = new TicketBiz(); Ticket t = ticketbiz.GetTicketById(id); //TicketCreateModel ticketcraetemodel= AutoMapper.Mapper.Map<TicketCreateModel>(t); TicketCreateModel ticketCreateModel = new TicketCreateModel(); ProductBiz productbiz = new ProductBiz(); ticketCreateModel.Products = productbiz.GetProducts(Convert.ToInt64(Session["CompanyId"])); ticketCreateModel.Priorities = ticketbiz.GetPriorities(); ticketCreateModel.Seviorities = ticketbiz.GetSeviorities(); ticketCreateModel.TicketTypes = ticketbiz.GetTicketTypes(); ticketCreateModel.Title = t.Title; ticketCreateModel.TicketId = t.TicketId; ticketCreateModel.Description = t.Description; ticketCreateModel.CompanyId = t.CompanyId; ticketCreateModel.ComponentId = t.ComponentId; ticketCreateModel.ProductId = t.ProductId; ticketCreateModel.VersionId = t.VersionId; ticketCreateModel.PriorityId = t.PriorityId; ticketCreateModel.SeviorityId = t.SeviorityId; ticketCreateModel.TicketTypeId = t.TicketTypeId; ticketCreateModel.ComponentName = t.ComponentName; ticketCreateModel.CompanyName = t.CompanyName; ticketCreateModel.ProductName = t.ProductName; long Id = ticketCreateModel.ProductId; ticketCreateModel.Components = productbiz.GetComponent(Id); ticketCreateModel.Versions = productbiz.GetVersions(Id); return(PartialView(ticketCreateModel)); //return ticketCreateModel; // return View("Create", ticketCreateModel); }
public ActionResult AddTicket(TicketCreateModel ticketModel) { var user = this.Data.Users.All().FirstOrDefault(u => u.UserName == this.User.Identity.Name); var category = this.Data.Categories.GetById(ticketModel.CategoryId); if (ModelState.IsValid) { var newTicket = new Ticket() { Title = ticketModel.Title, User = user, Description = ticketModel.Description, ImageUrl = ticketModel.ImageUrl, Priority = ticketModel.Priority, Category = category }; user.Points += 1; this.Data.Tickets.Add(newTicket); this.Data.SaveChanges(); return(Redirect("~/Ticket/Details/" + newTicket.Id)); } return(View("CreateTicket", ticketModel)); }
public async Task <IActionResult> CreateTicket([FromBody] TicketCreateModel ticket) { var steamId = User.GetSteamId(); if (!ModelState.IsValid) { return(BadRequest(ticket)); } var res = await _ticketService.UserCreateTicket(new UserCreateTicketRequest { Message = new InputMessage { MessageBody = ticket.Message, Name = "User" }, SteamId = steamId, Title = ticket.Title }); if (res.DataCase == SingleTicketResponse.DataOneofCase.Error) { return(new ObjectResult(res.Error) { StatusCode = 503 }); } return(Ok(res)); }
// GET: /CreatTicket/ public ActionResult Create() { ProductStore<Product> productStore = new ProductStore<Product>(); TicketCreateModel model = new TicketCreateModel(); model.Modules = new List<Module>(); model.Modules.Add(new Module() { Id = 1, Name = "Tickets" }); model.Modules.Add(new Module() { Id = 2, Name = "Contacts" }); model.Modules.Add(new Module() { Id = 3, Name = "Invoices" }); ProductManager<Product> productManager = new ProductManager<Product>(productStore); model.Products = productManager.GetAllProducts(); model.Products.Insert(0, new Product() { Id = 0, Name = "Select Product" }); //TicketManager<Ticket> ticketManager = new TicketManager<Ticket>(new TicketStore<Ticket>()); //model.Products = new List<Product>(); //model.Products=ticketManager.GetProduct(); model.Priorities = new List<Priority>(); model.Priorities.Add(new Priority() { Code = 1, Name = "High" }); model.Priorities.Add(new Priority() { Code = 2, Name = "Medium" }); model.Priorities.Add(new Priority() { Code = 3, Name = "Low" }); model.Priorities.Add(new Priority() { Code = 1, Name = "Critical" }); model.Priorities.Add(new Priority() { Code = 1, Name = "Blocker" }); return View(model); }
public async Task <IActionResult> CreateTicket(TicketCreateModel model) { var result = await _ticketService.CreateTicket(model); await this._hubContext.Clients.All.SendAsync("newTicket", result); return(Ok(result)); }
public static Ticket ToModel(this TicketCreateModel ticket) { return(new Ticket() { Title = ticket.Title, Description = ticket.Description, }); }
public IActionResult Create(TicketCreateModel model) { var newTicket = new Ticket { Application = model.App, TicketType = model.Type, Urgency = model.Urgency, Description = model.Description }; newTicket = _ticketData.Add(newTicket); return(RedirectToAction(nameof(Details), new { id = newTicket.Id })); }
public async Task <TicketModel> CreateTicket(TicketCreateModel model) { var entity = _mapper.Map <tblTicket>(model); entity.Status = 1; var ticket = await _unitOfWork.TicketRepository.Add(entity); await _unitOfWork.Commit(); var result = _mapper.Map <TicketModel>(ticket); return(result); }
public IActionResult Create(TicketCreateModel ticketCreateModel) { if (ModelState.IsValid) { var domainModel = ticketCreateModel.ToModel(); domainModel.UserId = int.Parse(User.FindFirst("Id").Value); var response = _ticketsService.CreateTicket(domainModel); return(RedirectToAction("Overview", "Ticket")); } else { return(View(ticketCreateModel)); } }
public ActionResult Create(TicketCreateModel m) { CRM.Model.Ticket ticket = new Model.Ticket(); ticket.Title = m.Title; //ticket.BranchId = 3; ticket.Description = m.Description; //ticket.Priority = m.SeverityCode; //ticket.TicketType = m.TicketType; //ticket.ModuleId = m.ModuleId; ticket.ProductId = m.ProductId; ticket.VersionId = m.VersionId; TicketManager<Ticket> ticketManager = new TicketManager<Ticket>(new TicketStore<Ticket>()); ticketManager.CreateTicket(ticket); return RedirectToAction("List"); }
// GET: Ticket public ActionResult Create(int?id) { TicketCreateModel ticketcreateModel = new TicketCreateModel(); try { int ticketid = Convert.ToInt32(id); //if (ticketid > 0) //ticketcreateModel = Edit(ticketid); ProductBiz productbiz = new ProductBiz(); // ViewBag.lstDropdown = ticketbiz.BindCompanies(); ticketcreateModel.Products = productbiz.GetProducts(Convert.ToInt64(Session["CompanyId"])); ticketcreateModel.Priorities = ticketbiz.GetPriorities(); ticketcreateModel.Seviorities = ticketbiz.GetSeviorities(); ticketcreateModel.TicketTypes = ticketbiz.GetTicketTypes(); // ticketcreateModel.lstproducts.Insert(0, new Product() { Id = 0, Name = "Select Product" }); //ViewBag.lstComponents = productbiz.GetComponents(); } catch (Exception ex) { ModelState.AddModelError("CT", ex.Message); } return(View(ticketcreateModel)); }
public ActionResult Create(TicketCreateModel T) { Ticket ticket = new Ticket(); TicketCreateModel ticketcreateModel = new TicketCreateModel(); try { ticket.TicketNo = T.TicketNo; ticket.Description = T.Description; ticket.Title = T.Title; ticket.VersionId = T.VersionId; ticket.ProductId = T.ProductId; ticket.CompanyId = T.CompanyId; ticket.ComponentId = T.ComponentId; ticket.SeviorityId = T.SeviorityId; ticket.PriorityId = T.PriorityId; ticket.TicketTypeId = T.TicketTypeId; ticket.CompanyId = Convert.ToInt32(Session["CompanyId"]); ticket.CreatedBy = Convert.ToInt64(Session["UID"]); TicketBiz ticketbiz = new TicketBiz(); ProductBiz productbiz = new ProductBiz(); ticketcreateModel.Products = productbiz.GetProducts(Convert.ToInt64(Session["CompanyId"])); ticketcreateModel.Priorities = ticketbiz.GetPriorities(); ticketcreateModel.Seviorities = ticketbiz.GetSeviorities(); ticketcreateModel.TicketTypes = ticketbiz.GetTicketTypes(); int i = ticketbiz.AddTicket(ticket); if (i > 0) { ViewBag.Message = "Ticket Successfully Insereted"; Templats template = new Templats(); TicketBiz ticketbz = new TicketBiz(); ticketbiz.GetTicketNo(); ticketbiz.getTemplate(); MailMessage email = new MailMessage(); // Sender e-mail address. email.From = new MailAddress("*****@*****.**"); // Recipient e-mail address. email.To.Add("*****@*****.**"); email.Subject = "TicketCreated"; email.Body = "Hi"; // remote SMTP server IP. SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.1and1.com"; smtp.Port = 587; smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "welcomewelcome"); try { smtp.Send(email); email = null; //ClientScript.RegisterStartupScript(GetType(), "alert", "<script>alert('Mail Sent Successfully...!')</script>"); } catch (Exception ex) { Exception ex2 = ex; string errorMessage = string.Empty; while (ex2 != null) { errorMessage += ex2.ToString(); ex2 = ex2.InnerException; } //ClientScript.RegisterStartupScript(GetType(), "alert", "<script>alert('Failure To Send Mail...')</script>"); } } else { ViewBag.ErrorMessage = " Inseret Failed"; } } catch (Exception ex) { ModelState.AddModelError("IT", ex.Message); } return(View(ticketcreateModel)); }
public ActionResult CreateTicket([Bind(Include = "moneyInvested,totalCoefficient,guesses,gameIds")] TicketCreateModel ticketCreate) { Ticket ticket = new Ticket(); ticket.time = DateTime.Now; ticket.totalCoefficient = ticketCreate.totalCoefficient; ticket.moneyInvested = ticketCreate.moneyInvested; ticket.guesses = ticketCreate.guesses; List <GameViewModelT> gameviews = new List <GameViewModelT>(); bool win = false; int[] realIds = new int[ticketCreate.gameIds.Length]; for (int i = 0; i < ticketCreate.gameIds.Length; i++) { int tempID = Convert.ToInt32(ticketCreate.gameIds[i]); realIds[i] = tempID; Game tempGame = db.Games.Find(tempID); if (tempGame.Completed && tempGame.Result == ticketCreate.guesses[i]) { win = true; } else { win = false; } if (tempGame != null) { GameViewModelT gameView = new GameViewModelT() { gameId = tempGame.ID, HalfTime = tempGame.HalfTime, team1 = db.Teams.Find(tempGame.Team1ID), team2 = db.Teams.Find(tempGame.Team2ID), start = tempGame.StartTime, end = tempGame.EndTime, team1Score = tempGame.team1Score, team2Score = tempGame.team2Score, completed = tempGame.Completed, Coefficient1 = tempGame.Coefficient1, Coefficient2 = tempGame.Coefficient2, Coefficient3 = tempGame.Coefficient3, outcome = tempGame.Result, Time = tempGame.Time }; gameviews.Add(gameView); } } ticket.win = win; ticket.gameIDs = realIds; db.tickets.Add(ticket); db.SaveChanges(); List <TicketDisplayViewModel> tickets1 = new List <TicketDisplayViewModel>(); string userID = User.Identity.GetUserId(); ApplicationUser user = db.Users.Include(m => m.tickets).SingleOrDefault(m => m.Id == userID); user.tickets.Add(ticket); db.Entry(user).State = EntityState.Modified; db.SaveChanges(); foreach (var item in user.tickets) { List <GameViewModelT> viewGames1 = new List <GameViewModelT>(); Ticket temp = db.tickets.Find(item.ID); bool iswon = false; for (int j = 0; j < temp.gameIDs.Length; j++) { Game tempGame = db.Games.Find(temp.gameIDs[j]); if (tempGame != null) { if (tempGame.Completed && tempGame.Result == item.guesses[j]) { iswon = true; } else { iswon = false; } GameViewModelT gameView = new GameViewModelT() { gameId = tempGame.ID, HalfTime = tempGame.HalfTime, team1 = db.Teams.Find(tempGame.Team1ID), team2 = db.Teams.Find(tempGame.Team2ID), start = tempGame.StartTime, end = tempGame.EndTime, team1Score = tempGame.team1Score, team2Score = tempGame.team2Score, completed = tempGame.Completed, Coefficient1 = tempGame.Coefficient1, Coefficient2 = tempGame.Coefficient2, Coefficient3 = tempGame.Coefficient3, outcome = tempGame.Result, Time = tempGame.Time }; viewGames1.Add(gameView); } } if (temp.win != iswon) { temp.win = iswon; db.Entry(temp).State = EntityState.Modified; db.SaveChanges(); } TicketDisplayViewModel tv = new TicketDisplayViewModel() { TicketID = temp.ID, totalCoefficient = temp.totalCoefficient, guesses = temp.guesses, games = viewGames1, moneyInvested = temp.moneyInvested, Result = temp.win, futureWinnings = temp.WinMoney, Time = temp.time }; tickets1.Add(tv); } return(View("ViewTickets", tickets1)); }
public ActionResult CreatingTicket(TicketGamesView tick) { TicketCreateModel ticketCreate = new TicketCreateModel(); string[] idgame = tick.ids.Split(','); string[] coefgame = tick.gameCoef.Split(','); List <GameViewModelT> selGames = new List <GameViewModelT>(); double totalCoef = 1; int[] gues = new int[idgame.Length]; for (int i = 0; i < idgame.Length; i++) { int tempID = Convert.ToInt32(idgame[i]); Game tempGame = db.Games.Find(tempID); if (tempGame != null) { GameViewModelT gameView = new GameViewModelT() { gameId = tempGame.ID, HalfTime = tempGame.HalfTime, team1 = db.Teams.Find(tempGame.Team1ID), team2 = db.Teams.Find(tempGame.Team2ID), start = tempGame.StartTime, end = tempGame.EndTime, team1Score = tempGame.team1Score, team2Score = tempGame.team2Score, completed = tempGame.Completed, Coefficient1 = tempGame.Coefficient1, Coefficient2 = tempGame.Coefficient2, Coefficient3 = tempGame.Coefficient3, outcome = tempGame.Result, Time = tempGame.Time }; if (coefgame[i].ToString().Equals("c1")) { totalCoef *= tempGame.Coefficient1; gues[i] = 1; } else if (coefgame[i].ToString().Equals("c2")) { totalCoef *= tempGame.Coefficient2; gues[i] = 0; } else if (coefgame[i].ToString().Equals("c3")) { totalCoef *= tempGame.Coefficient3; gues[i] = 2; } selGames.Add(gameView); } } /* ticket.games = selGames; * ticket.totalCoefficient = totalCoef; * ticket.time = DateTime.Now; * ticket.guesses = gues;*/ ticketCreate.totalCoefficient = totalCoef; ticketCreate.gameIds = idgame; ticketCreate.games = selGames; ticketCreate.guesses = gues; return(View(ticketCreate)); }