public async Task <IActionResult> Create(StockReceiveMastVM stockReceiveMastVM) { var stockReceiveMast = new StockReceiveMast(); stockReceiveMast.EntryDate = System.DateTime.Now.Date; stockReceiveMast.EntryUserID = 1; if (ModelState.IsValid) { stockReceiveMast.PortfolioAcId = stockReceiveMastVM.PortfolioAcId; stockReceiveMast.ValueDate = stockReceiveMastVM.ValueDate; stockReceiveMast.Remarks = stockReceiveMastVM.Remarks; stockReceiveMast.StockReceiveDetls = stockReceiveMastVM.StockRecieveDetlVM.Select(a => new StockReceiveDetl { StockId = a.StockId, OwnershipDate = a.OwnershipDate, Qty = a.Qty, Rate = a.Rate }).ToList(); _context.Add(stockReceiveMast); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PortfolioAcId"] = new SelectList(_context.PortfolioAccount, "Id", "AccountName", stockReceiveMast.PortfolioAcId); return(View(stockReceiveMast)); }
public async Task <IActionResult> Create([Bind("pcategoryid,category")] ProductCategory productCategory) { if (ModelState.IsValid) { _context.Add(productCategory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(productCategory)); }
public ServiceResult <Stock> SaveStock(Stock stock) { using (var dbContextTransaction = _context.Database.BeginTransaction()) { _context.Add(stock); _context.SaveChanges(); dbContextTransaction.Commit(); } return(new ServiceResult <Stock>() { Data = null, Message = "Success", Status = ResultStatus.Success }); }
public async Task <IActionResult> Create([Bind("productid,pname,description,pcategoryid,price,availableqty,imagefile,isavailable")] Product product) { if (HttpContext.Session.GetString("FNAME") != null) { ViewBag.positionid = HttpContext.Session.GetString("POSITIONID"); ViewBag.firstname = HttpContext.Session.GetString("FNAME"); ViewBag.positionid = HttpContext.Session.GetString("POSITIONID"); ViewBag.teacherid = HttpContext.Session.GetString("TEACHERID"); ViewBag.adminid = HttpContext.Session.GetString("ADMINID"); ViewBag.studentid = HttpContext.Session.GetString("STUDENTID"); int ids = Convert.ToInt32(ViewBag.studentid); var targetForWallet = _context.tblWallet.Where(x => x.studentid == ids).FirstOrDefault(); int walletqty = targetForWallet.cash; HttpContext.Session.SetString("walletqty", Convert.ToString(walletqty)); ViewBag.walletqty = HttpContext.Session.GetString("walletqty"); var target = _context.tblCart.Where(s => s.studentid == ids).ToList(); int countqty = target.Sum(x => x.quantity); HttpContext.Session.SetString("countqty", Convert.ToString(countqty)); ViewBag.numberofqty = HttpContext.Session.GetString("countqty"); string wwwRootPath = _hostenvironment.WebRootPath; string fileName = Path.GetFileNameWithoutExtension(product.imagefile.FileName); string extension = Path.GetExtension(product.imagefile.FileName); product.imagename = fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; string path = Path.Combine(wwwRootPath + "/image/", fileName); using (var fileStream = new FileStream(path, FileMode.Create)) { await product.imagefile.CopyToAsync(fileStream); } _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index", "Signin")); } }
public async Task <IActionResult> Create(FlightsCreateViewModel createModel) { if (ModelState.IsValid) { Flight flight = new Flight { LocationFrom = createModel.LocationFrom, LocationTo = createModel.LocationTo, Going = createModel.Going, Return = createModel.Return, TypeOfPlane = createModel.TypeOfPlane, NameOfAviator = createModel.NameOfAviator, CapacityOfEconomyClass = createModel.CapacityOfEconomyClass, CapacityOfBusinessClass = createModel.CapacityOfBusinessClass }; _context.Add(flight); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(createModel)); }
public async Task <IActionResult> Create([Bind("adminid,firstname,lastname,dob,email,positionid,username,password")] Admin admin) { if (HttpContext.Session.GetString("FNAME") != null) { ViewBag.positionid = HttpContext.Session.GetString("POSITIONID"); ViewBag.firstname = HttpContext.Session.GetString("FNAME"); ViewBag.teacherid = HttpContext.Session.GetString("TEACHERID"); ViewBag.adminid = HttpContext.Session.GetString("ADMINID"); ViewBag.studentid = HttpContext.Session.GetString("STUDENTID"); if (ModelState.IsValid) { _context.Add(admin); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(admin)); } else { return(RedirectToAction("Index", "Signin")); } }
public async Task <IActionResult> Create(ReservationsCreateViewModel createModel) { if (ModelState.IsValid) { Reservation reservation = new Reservation { FirstName = createModel.FirstName, SecondName = createModel.SecondName, LastName = createModel.LastName, EGN = createModel.EGN, PhoneNumber = createModel.PhoneNumber, Nationality = createModel.Nationality, TypeOfTicket = createModel.TypeOfTicket, Email = createModel.Email }; _context.Add(reservation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(createModel)); }
public IActionResult Created(Coursename coursenames) { if (HttpContext.Session.GetString("FNAME") != null) { ViewBag.positionid = HttpContext.Session.GetString("POSITIONID"); ViewBag.firstname = HttpContext.Session.GetString("FNAME"); ViewBag.positionid = HttpContext.Session.GetString("POSITIONID"); ViewBag.teacherid = HttpContext.Session.GetString("TEACHERID"); ViewBag.adminid = HttpContext.Session.GetString("ADMINID"); ViewBag.studentid = HttpContext.Session.GetString("STUDENTID"); _context.Add(coursenames); _context.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index", "Signin")); } }
public async Task <IActionResult> Create(UsersCreateViewModel createModel) { if (ModelState.IsValid) { User user = new User { UserName = createModel.UserName, Password = createModel.Password, Email = createModel.Email, FirstName = createModel.FirstName, LastName = createModel.LastName, EGN = createModel.EGN, Address = createModel.Address, PhoneNumber = createModel.PhoneNumber, Role = createModel.Role }; _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(createModel)); }
public IActionResult AddMeeting(Meeting meeting) { if (HttpContext.Session.GetString("FNAME") != null) { ViewBag.positionid = HttpContext.Session.GetString("POSITIONID"); ViewBag.firstname = HttpContext.Session.GetString("FNAME"); ViewBag.teacherid = HttpContext.Session.GetString("TEACHERID"); ViewBag.adminid = HttpContext.Session.GetString("ADMINID"); ViewBag.studentid = HttpContext.Session.GetString("STUDENTID"); int ids = Convert.ToInt32(ViewBag.studentid); int countMsg = _context.tblInbox.Count(x => x.studentid == ids); HttpContext.Session.SetString("countMsg", Convert.ToString(countMsg)); ViewBag.numberofmsg = HttpContext.Session.GetString("countMsg"); List <Meeting> listofmeeting = _context.tblMeeting.ToList(); //ViewBag.Listofteacher = ListOfTeachers; List <Student> listofstudent = _context.tblStudent.ToList(); List <MeetingTime> listofmeetingtime = _context.tblMeetingTime.ToList(); List <Teacher> ListOfTeachers = _context.tblTeacher.ToList(); ViewBag.ListOfTeachers = ListOfTeachers; ViewBag.listofmeetingtime = listofmeetingtime; var joinedtable = from me in listofmeeting join s in listofstudent on me.studentid equals s.studentid join mt in listofmeetingtime on me.meetingtimeid equals mt.meetingtimeid join t in ListOfTeachers on me.teacherid equals t.teacherid select new NewVM { listofstudent = s, listofmeeting = me, listofmeetingtime = mt, ListOfTeachers = t }; Meeting m = new Meeting(); var checker = joinedtable.Where(x => x.ListOfTeachers.teacherid == meeting.teacherid && x.listofmeeting.dateofmeeting == meeting.dateofmeeting && x.listofmeetingtime.meetingtimeid == meeting.meetingtimeid).FirstOrDefault(); if (checker == null) { m.studentid = Convert.ToInt32(ViewBag.studentid); m.requestedtime = DateTime.Now; DateTime dateofmeeting = meeting.dateofmeeting.Date; m.dateofmeeting = dateofmeeting; m.meetingtimeid = meeting.meetingtimeid; m.teacherid = meeting.teacherid; m.status = "Incomplete"; m.about = meeting.about; _context.Add(m); _context.SaveChanges(); TempData["success"] = "Your appointment scheduled successfully"; //ViewBag.positionid = HttpContext.Session.GetString("POSITIONID"); return(RedirectToAction("Create")); } else { TempData["duprecord"] = "This time slot is already booked. Try Again!"; return(RedirectToAction("Create")); } } else { return(RedirectToAction("Index", "Signin")); } }