private List <TravelRequests> ViewApprovalTravelRequests(int level, string employeeCode = "") { using (BTCEntities db = new BTCEntities()) { if (!string.IsNullOrEmpty(employeeCode) && level != 2) { using (EmployeeDetailsDBService EmpDBService = new EmployeeDetailsDBService(empCode)) { List <string> EmpCodes = EmpDBService.EmployeesUnderDepartmentHeadDetails(empCode); var tr = db.TravelRequests.Include(a => a.City).Include(a => a.City1).Include(a => a.Users).Include(a => a.Users1).Where(a => a.ApprovalLevel == level).ToList(); var trf = tr.Where(a => EmpCodes.Any(s => s.Equals(a.Users1.HRW_Employee.EmployeeCode))).ToList(); return(trf); } } else if (level == 2) { var tr = db.TravelRequests.Include(a => a.City).Include(a => a.City1).Include(a => a.Users).Include(a => a.Users1).Where(a => a.ApprovalLevel == level).ToList(); return(tr); } else { var tr = db.TravelRequests.Include(a => a.City).Include(a => a.City1).Include(a => a.Users).Include(a => a.Users1).Where(a => a.ApprovalLevel == level).ToList(); return(tr); } } }
public async Task <ActionResult> LPOProcessing(int?id) { using (BTCEntities db = new BTCEntities()) { db.Configuration.LazyLoadingEnabled = false; db.Configuration.ProxyCreationEnabled = true; var RFQList = await db.RFQ.Include(a => a.TravelRequests).Include(a => a.LPO).Include(a => a.TravelAgency).Include(a => a.Users).Include(a => a.Quotation).Include("Quotation.ATQuotation").Include("Quotation.HSQuotation").Include("Quotation.PCQuotation").Where(a => a.Processing == (int)ProcessingStatus.BeingProcessed && a.TravelRequestID == id).Distinct().ToListAsync(); if (RFQList.Count > 0) { ViewBag.RFQList = RFQList; ViewBag.TravelAgency = db.TravelAgency.ToList(); ViewBag.Cities = db.City.ToList(); ViewBag.Currencies = db.Currency.ToList(); ViewBag.ApprovalBy = db.Users.ToList(); using (EmployeeDetailsDBService EmpDBService = new EmployeeDetailsDBService("", RFQList[0].TravelRequests.Users1.HREmployeeID.ToString())) { ViewBag.FullEmployeeDetails = EmpDBService.FullEmployeeDetails(); } return(View(RFQList.ToList())); } else { return(RedirectToAction("Index", new { id = id })); } } }
public string GetEmployeeDetails(string id) { using (EmployeeDetailsDBService employeeDetailsDBService = new EmployeeDetailsDBService("", id)) { return(new JavaScriptSerializer().Serialize(employeeDetailsDBService.FullEmployeeDetails())); } }
public async Task <ActionResult> AddQuotation(int id) { using (BTCEntities db = new BTCEntities()) { if (id <= 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RFQ rFQ = await db.RFQ.Include(a => a.TravelRequests).Include(a => a.TravelAgency).Include(a => a.Users).Include(a => a.TravelRequests.Quotation).Include("Quotation.ATQuotation").Include("Quotation.HSQuotation").Include("Quotation.PCQuotation").Where(a => a.ID == id).FirstOrDefaultAsync(); if (rFQ == null) { return(HttpNotFound()); } ViewBag.TravelAgency = db.TravelAgency.ToList(); ViewBag.Cities = db.City.ToList(); ViewBag.Currencies = db.Currency.ToList(); ViewBag.ApprovalBy = db.Users.ToList(); using (EmployeeDetailsDBService EmpDBService = new EmployeeDetailsDBService("", rFQ.TravelRequests.Users1.HREmployeeID.ToString())) { ViewBag.FullEmployeeDetails = EmpDBService.FullEmployeeDetails(); } //ViewBag.fileUploader = db.AttachmentLink.Where(a => a.AttachmentFor.Contains(rFQ.TravelRequests.ApplicationNumber)).Select(x => x.Attachments).Include(a => a.AttachmentLink).Include(a => a.Users)?.ToList(); return(View(rFQ)); } }
public ActionResult HRApprovalForm(int id) { try { if (id <= 0) { ViewBag.ErrorMessage = "No Travel Request ID"; return(View()); //return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Invalid Travel Request ID"); } using (BTCEntities db = new BTCEntities()) { TravelRequests travelRequest = db.TravelRequests.Include(a => a.Users).Include(a => a.Users1).Include("Users1.HRW_Employee").Include("Users.HRW_Employee").SingleOrDefault(s => s.ID == id); if (travelRequest == null) { ViewBag.ErrorMessage = "Invalid Travel Request ID"; return(View()); //return HttpNotFound("Invalid Travel Request ID"); } ViewBag.Cities = db.City.ToList(); ViewBag.Currencies = db.Currency.ToList(); ViewBag.ApprovalBy = db.Users.ToList(); using (EmployeeDetailsDBService EmpDBService = new EmployeeDetailsDBService(travelRequest.Users1.HRW_Employee.EmployeeCode)) { ViewBag.FullEmployeeDetails = EmpDBService.FullEmployeeDetails(); } return(View(travelRequest)); } } catch (Exception e) { throw e; } }
public ActionResult EmployeeDetails() { EmployeeDetailsDBService employeeDetailsDBService = new EmployeeDetailsDBService(empCode); ViewBag.FullEmployeeDetails = employeeDetailsDBService.FullEmployeeDetails(); return(View()); }
public ActionResult AnyEmployeeDetails(string id) { using (EmployeeDetailsDBService employeeDetailsDBService = new EmployeeDetailsDBService("", id)) { var FullEmployeeDetails = employeeDetailsDBService.FullEmployeeDetails(); return(View(FullEmployeeDetails)); } }
public async Task <ActionResult> RFQFinalPreview(int?id) { using (BTCEntities db = new BTCEntities()) { ViewBag.TravelAgency = db.TravelAgency.ToList(); ViewBag.Cities = db.City.ToList(); ViewBag.Currencies = db.Currency.ToList(); ViewBag.ApprovalBy = db.Users.ToList(); RFQ rfqlist = await db.RFQ.Include(a => a.TravelRequests).Include(a => a.TravelAgency).Include(a => a.Users).Where(a => a.ID == id).FirstOrDefaultAsync(); ViewBag.fileUploader = db.AttachmentLink.Where(a => a.AttachmentFor == (rfqlist.RFQName + "Pro" + rfqlist.ProcessingSection + "Trav" + rfqlist.TravelAgencyID)).Select(x => x.Attachments).ToList(); MasterRFQ = rfqlist; if (rfqlist.ProcessingSection == (int)ProcessingSections.AT || rfqlist.ProcessingSection == (int)ProcessingSections.ATHS || rfqlist.ProcessingSection == (int)ProcessingSections.ATHSPC || rfqlist.ProcessingSection == (int)ProcessingSections.ATPC) { ATQuotation atquot = new ATQuotation(); atquot.DestinationID = rfqlist.TravelRequests.PortOfDestinationID; atquot.DepartureDate = rfqlist.TravelRequests.DepartureDate; atquot.DepartureTime = rfqlist.TravelRequests.DepartureTime; atquot.OriginID = rfqlist.TravelRequests.PortOfOriginID; atquot.ReturnDate = rfqlist.TravelRequests.ReturnDate; atquot.ReturnTime = rfqlist.TravelRequests.ReturnTime; atquot.TicketClass = rfqlist.TravelRequests.TicketClass; ViewBag.ATQuotation = atquot; } if (rfqlist.ProcessingSection == (int)ProcessingSections.ATHS || rfqlist.ProcessingSection == (int)ProcessingSections.ATHSPC || rfqlist.ProcessingSection == (int)ProcessingSections.HS || rfqlist.ProcessingSection == (int)ProcessingSections.HSPC) { HSQuotation hsquot = new HSQuotation(); hsquot.CheckInDate = rfqlist.TravelRequests.CheckInDate; hsquot.CheckInTime = rfqlist.TravelRequests.CheckInTime; hsquot.CheckOutDate = rfqlist.TravelRequests.CheckOutDate; hsquot.CheckOutTime = rfqlist.TravelRequests.CheckOutTime; hsquot.HotelCategory = rfqlist.TravelRequests.HotelCategory; hsquot.HotelName = rfqlist.TravelRequests.HotelName; hsquot.RoomCategory = rfqlist.TravelRequests.RoomCategory; hsquot.RoomType = rfqlist.TravelRequests.RoomType; ViewBag.HSQuotation = hsquot; } if (rfqlist.ProcessingSection == (int)ProcessingSections.ATHSPC || rfqlist.ProcessingSection == (int)ProcessingSections.ATPC || rfqlist.ProcessingSection == (int)ProcessingSections.HSPC || rfqlist.ProcessingSection == (int)ProcessingSections.PC) { PCQuotation pcquot = new PCQuotation(); pcquot.DropOffDate = rfqlist.TravelRequests.DropOffDate; pcquot.DropoffLocation = rfqlist.TravelRequests.DropOffLocation; pcquot.DropOffTime = rfqlist.TravelRequests.DropOffTime; pcquot.PickUpDate = rfqlist.TravelRequests.PickUpDate; pcquot.PickupLocation = rfqlist.TravelRequests.PickUpLocation; pcquot.PickUpTime = rfqlist.TravelRequests.PickUpTime; pcquot.PreferredVehicle = rfqlist.TravelRequests.PreferredVehicle; ViewBag.PCQuotation = pcquot; } using (EmployeeDetailsDBService EmpDBService = new EmployeeDetailsDBService("", rfqlist.TravelRequests.Users1.HREmployeeID.ToString())) { ViewBag.FullEmployeeDetails = EmpDBService.FullEmployeeDetails(); } return(View(rfqlist)); } }
public ActionResult ManageEmployees() { List <FullEmployeeDetail> employeeList = new List <FullEmployeeDetail>(); using (EmployeeDetailsDBService db = new EmployeeDetailsDBService(empCode)) { ViewBag.employeeList = db.AllEmployeeDetails(); } return(View()); }
public ActionResult CreateUser() { using (BTCEntities db = new BTCEntities()) { List <Roles> allRoles = db.Roles.ToList(); List <FullEmployeeDetail> allEmployees = new List <FullEmployeeDetail>(); using (EmployeeDetailsDBService employeeDetailsDBService = new EmployeeDetailsDBService(empCode)) { allEmployees = employeeDetailsDBService.AllEmployeeDetails(); } ViewBag.allRoles = allRoles; ViewBag.allEmployees = allEmployees; CheckErrorMessages(); return(View()); } }
public ActionResult AdminDashboard() { List <Users> usersList = new List <Users>(); using (BTCEntities db = new BTCEntities()) { ViewBag.usersList = db.Users.Include(a => a.Roles).Include(a => a.HRW_Employee).ToList(); } List <FullEmployeeDetail> employeeList = new List <FullEmployeeDetail>(); using (EmployeeDetailsDBService db = new EmployeeDetailsDBService(empCode)) { ViewBag.employeeList = db.AllEmployeeDetails(50); } return(View()); }
public async Task <ActionResult> LPODetails(int id) { using (BTCEntities db = new BTCEntities()) { ViewBag.TravelAgency = db.TravelAgency.ToList(); ViewBag.Cities = db.City.ToList(); ViewBag.Currencies = db.Currency.ToList(); ViewBag.ApprovalBy = db.Users.ToList(); var LPO = db.LPO.Include(a => a.RFQ).Include(a => a.Quotation).Include(a => a.RFQ).Include("Quotation.TravelRequests").Include("RFQ.TravelRequests").Include("Quotation.ATQuotation").Include("Quotation.HSQuotation").Include("Quotation.PCQuotation").Where(a => a.ID == id).FirstOrDefault(); if (LPO.Quotation.ATQuotation.Where(b => b.IsLowest == true).ToList().Count > 0) { var atqouteid = LPO.Quotation.ATQuotation.Where(b => b.IsLowest == true).FirstOrDefault().ID; if (db.AttachmentLink.Where(a => a.AttachmentFor.Contains(LPO.Quotation.TravelRequests.ApplicationNumber + ".AT-Q" + atqouteid)).Count() > 0) { ViewData.Add("ATfileUploader" + atqouteid, db.AttachmentLink.Where(a => a.AttachmentFor == LPO.Quotation.TravelRequests.ApplicationNumber + ".AT-Q" + atqouteid).Select(x => x.Attachments).Include(a => a.AttachmentLink).Include(a => a.Users)?.ToList()); } } if (LPO.Quotation.HSQuotation.Where(b => b.IsLowest == true).ToList().Count > 0) { var hsqouteid = LPO.Quotation.HSQuotation.Where(b => b.IsLowest == true).FirstOrDefault().ID; if (db.AttachmentLink.Where(a => a.AttachmentFor.Contains(LPO.Quotation.TravelRequests.ApplicationNumber + ".HS-Q" + hsqouteid)).Count() > 0) { ViewData.Add("HSfileUploader" + hsqouteid, db.AttachmentLink.Where(a => a.AttachmentFor == LPO.Quotation.TravelRequests.ApplicationNumber + ".HS-Q" + hsqouteid).Select(x => x.Attachments).Include(a => a.AttachmentLink).Include(a => a.Users)?.ToList()); } } if (LPO.Quotation.PCQuotation.Where(b => b.IsLowest == true).ToList().Count > 0) { var pcqouteid = LPO.Quotation.PCQuotation.Where(b => b.IsLowest == true).FirstOrDefault().ID; if (db.AttachmentLink.Where(a => a.AttachmentFor.Contains(LPO.Quotation.TravelRequests.ApplicationNumber + ".PC-Q" + pcqouteid)).Count() > 0) { ViewData.Add("PCfileUploader" + pcqouteid, db.AttachmentLink.Where(a => a.AttachmentFor == LPO.Quotation.TravelRequests.ApplicationNumber + ".PC-Q" + pcqouteid).Select(x => x.Attachments).Include(a => a.AttachmentLink).Include(a => a.Users)?.ToList()); } } using (EmployeeDetailsDBService EmpDBService = new EmployeeDetailsDBService("", LPO.Quotation.TravelRequests.Users1.HREmployeeID.ToString())) { ViewBag.FullEmployeeDetails = EmpDBService.FullEmployeeDetails(); } return(View(LPO)); } }
public async Task <ActionResult> RFQProcessing(int?id) { using (BTCEntities db = new BTCEntities()) { ViewBag.Cities = db.City.ToList(); ViewBag.Currencies = db.Currency.ToList(); ViewBag.ApprovalBy = db.Users.ToList(); ViewBag.TravelAgency = db.TravelAgency.ToList(); TravelRequests travelRequest = await db.TravelRequests.Include(a => a.RFQ).Where(a => a.ID == id).FirstOrDefaultAsync(); using (EmployeeDetailsDBService EmpDBService = new EmployeeDetailsDBService("", travelRequest.Users1.HREmployeeID.ToString())) { ViewBag.FullEmployeeDetails = EmpDBService.FullEmployeeDetails(); } ViewBag.AvailableCombinations = db.RFQ.Where(a => a.TravelRequestID == id && a.IsDeleted == false).ToList(); return(View(travelRequest)); } }
public ActionResult DeleteRFQ(int?id) { using (BTCEntities db = new BTCEntities()) { RFQ rfqitem = db.RFQ.Include(a => a.TravelRequests).Include(a => a.TravelAgency).Include(a => a.Users).Where(a => a.ID == id).FirstOrDefault(); if (ModelState.IsValid) { rfqitem.IsDeleted = true; db.RFQ.Attach(rfqitem); var entry = db.Entry(rfqitem); entry.Property(a => a.IsDeleted).IsModified = true; db.SaveChanges(); return(RedirectToAction("Index")); } else { var errlist = ModelState.Values.Where(e => e.Errors.Count > 0).Select(a => a.Errors); List <string> sberr = new List <string>(); foreach (var item in errlist) { sberr.Add(item[0].ErrorMessage); } TempData["ErrorMessage"] = sberr.ToList(); } ViewBag.TravelAgency = db.TravelAgency.ToList(); ViewBag.Cities = db.City.ToList(); ViewBag.Currencies = db.Currency.ToList(); ViewBag.ApprovalBy = db.Users.ToList(); ViewBag.fileUploader = db.AttachmentLink.Where(a => a.AttachmentFor == (rfqitem.RFQName + "Pro" + rfqitem.ProcessingSection + "Trav" + rfqitem.TravelAgencyID)).Select(x => x.Attachments).ToList(); MasterRFQ = rfqitem; using (EmployeeDetailsDBService EmpDBService = new EmployeeDetailsDBService("", rfqitem.TravelRequests.Users1.HREmployeeID.ToString())) { ViewBag.FullEmployeeDetails = EmpDBService.FullEmployeeDetails(); } return(View(rfqitem)); } }
public ActionResult ApproveManagerRequest(FormCollection collection) { using (BTCEntities db = new BTCEntities()) { var id = Convert.ToInt32(collection["ID"]); TravelRequests travelRequest = db.TravelRequests.Include(a => a.Users).Include(a => a.Users1).Include("Users1.HRW_Employee").Include("Users.HRW_Employee").SingleOrDefault(s => s.ID == id); if (ModelState.IsValid) { travelRequest.AdditionalAllowance = Convert.ToInt32(collection["AdditionalAllowance"]); travelRequest.ApprovalLevel = (int)ApprovalLevels.ApprovedByManager; travelRequest.ApprovalBy = dbuser.ID; travelRequest.ApprovalRemarks = travelRequest.ApprovalRemarks + "\n Manager Remarks: Approved By -" + dbuser.FirstName + ", " + dbuser.LastName + " \n Updated On: " + DateTime.Now.ToLongDateString() + " \n Comments: " + collection["ApprovalRemarksUser"]; db.Entry(travelRequest).State = EntityState.Modified; db.SaveChanges(); //NotificationEmail(travelRequest, true); return(RedirectToAction("ManagerDashboard")); } else { var errlist = ModelState.Values.Where(e => e.Errors.Count > 0).Select(a => a.Errors); List <string> sberr = new List <string>(); foreach (var item in errlist) { sberr.Add(item[0].ErrorMessage); } TempData["ErrorMessage"] = sberr.ToList(); } ViewBag.Cities = db.City.ToList(); ViewBag.Currencies = db.Currency.ToList(); ViewBag.ApprovalBy = db.Users.ToList(); using (EmployeeDetailsDBService EmpDBService = new EmployeeDetailsDBService(travelRequest.Users1.HRW_Employee.EmployeeCode)) { ViewBag.FullEmployeeDetails = EmpDBService.FullEmployeeDetails(); } return(View(travelRequest)); } }
public ActionResult PreviewRFQ(RFQ rfq) { using (BTCEntities db = new BTCEntities()) { if (ModelState.IsValid) { var dbrfq = db.RFQ.Find(rfq.ID); dbrfq.Processing = (int)ProcessingStatus.BeingProcessed; dbrfq.UserID = dbuser.ID; dbrfq.Remarks = rfq.Remarks; dbrfq.IsDeleted = rfq.IsDeleted; db.RFQ.Attach(dbrfq); var entry = db.Entry(dbrfq); entry.State = EntityState.Modified; entry.Property(a => a.Remarks).IsModified = true; entry.Property(a => a.UserID).IsModified = true; entry.Property(a => a.Processing).IsModified = true; entry.Property(a => a.IsDeleted).IsModified = true; db.SaveChanges(); Quotation quote = new Quotation { TravelRequestID = (int)dbrfq.TravelRequestID, IsDeleted = true, RFQID = rfq.ID }; db.Quotation.Add(quote); db.SaveChanges(); db.Configuration.ValidateOnSaveEnabled = false; var travelreq = db.TravelRequests.Where(a => a.ID == rfq.TravelRequestID).FirstOrDefault(); ATQuotation ATquote = new ATQuotation() { QuotationID = quote.ID, QuotationName = travelreq.ApplicationNumber + " / AT - Q", City = travelreq.City, City1 = travelreq.City1, DepartureDate = travelreq.DepartureDate, DepartureTime = travelreq.DepartureTime, DestinationID = travelreq.City.ID, OriginID = travelreq.City1.ID, ReturnDate = travelreq.ReturnDate, ReturnTime = travelreq.ReturnTime, TicketClass = travelreq.TicketClass, IsActive = false, IsDeleted = false }; db.ATQuotation.Add(ATquote); HSQuotation HSquote = new HSQuotation() { QuotationID = quote.ID, QuotationName = db.TravelRequests.Where(a => a.ID == rfq.TravelRequestID).FirstOrDefault().ApplicationNumber + " / HS - Q", CheckInDate = travelreq.CheckInDate, CheckInTime = travelreq.CheckInTime, CheckOutDate = travelreq.CheckOutDate, CheckOutTime = travelreq.CheckOutTime, HotelCategory = travelreq.HotelCategory, RoomCategory = travelreq.RoomCategory, RoomType = travelreq.RoomType, IsActive = false, IsDeleted = false }; db.HSQuotation.Add(HSquote); PCQuotation PCquote = new PCQuotation() { QuotationID = quote.ID, QuotationName = db.TravelRequests.Where(a => a.ID == rfq.TravelRequestID).FirstOrDefault().ApplicationNumber + " / PC - Q", DropOffDate = travelreq.DropOffDate, DropoffLocation = travelreq.DropOffLocation, DropOffTime = travelreq.DropOffTime, PickUpDate = travelreq.PickUpDate, PickupLocation = travelreq.PickUpLocation, PickUpTime = travelreq.PickUpTime, PreferredVehicle = travelreq.PreferredVehicle, IsActive = false, IsDeleted = false }; db.PCQuotation.Add(PCquote); db.SaveChanges(); MasterRFQ = dbrfq; return(RedirectToAction("RFQPostMerger", new { id = rfq.TravelRequestID })); } else { var errlist = ModelState.Values.Where(e => e.Errors.Count > 0).Select(a => a.Errors); List <string> sberr = new List <string>(); foreach (var item in errlist) { sberr.Add(item[0].ErrorMessage); } TempData["ErrorMessage"] = sberr.ToList(); } ViewBag.TravelAgency = db.TravelAgency.ToList(); ViewBag.Cities = db.City.ToList(); ViewBag.Currencies = db.Currency.ToList(); ViewBag.ApprovalBy = db.Users.ToList(); RFQ rfqitem = db.RFQ.Include(a => a.TravelRequests).Include(a => a.TravelAgency).Include(a => a.Users).Where(a => a.ID == rfq.ID).FirstOrDefault(); ViewBag.fileUploader = db.AttachmentLink.Where(a => a.AttachmentFor == (rfqitem.RFQName + "Pro" + rfqitem.ProcessingSection + "Trav" + rfqitem.TravelAgencyID)).Select(x => x.Attachments).ToList(); MasterRFQ = rfqitem; using (EmployeeDetailsDBService EmpDBService = new EmployeeDetailsDBService("", rfqitem.TravelRequests.Users1.HREmployeeID.ToString())) { ViewBag.FullEmployeeDetails = EmpDBService.FullEmployeeDetails(); } return(View(rfqitem)); } }
public ActionResult RFQProcessing(TravelRequests travelRequest, FormCollection formCollection) { RFQ rfq = new RFQ { TravelRequestID = travelRequest.ID }; if (formCollection.AllKeys.Contains("checkAll") && formCollection["checkAll"].ToString().ToLower() == "on") { rfq.ProcessingSection = (int)ProcessingSections.ATHSPC; } else { if ((formCollection.AllKeys.Contains("ATCheck") && formCollection["ATCheck"].ToString().ToLower() == "on") && (formCollection.AllKeys.Contains("HSCheck") && formCollection["HSCheck"].ToString().ToLower() == "on")) { rfq.ProcessingSection = (int)ProcessingSections.ATHS; } else if ((formCollection.AllKeys.Contains("ATCheck") && formCollection["ATCheck"].ToString().ToLower() == "on") && (formCollection.AllKeys.Contains("PCCheck") && formCollection["PCCheck"].ToString().ToLower() == "on")) { rfq.ProcessingSection = (int)ProcessingSections.ATPC; } else if ((formCollection.AllKeys.Contains("PCCheck") && formCollection["PCCheck"].ToString().ToLower() == "on") && (formCollection.AllKeys.Contains("HSCheck") && formCollection["HSCheck"].ToString().ToLower() == "on")) { rfq.ProcessingSection = (int)ProcessingSections.HSPC; } else if ((formCollection.AllKeys.Contains("ATCheck") && formCollection["ATCheck"].ToString().ToLower() == "on")) { rfq.ProcessingSection = (int)ProcessingSections.AT; } else if ((formCollection.AllKeys.Contains("HSCheck") && formCollection["HSCheck"].ToString().ToLower() == "on")) { rfq.ProcessingSection = (int)ProcessingSections.HS; } else if ((formCollection.AllKeys.Contains("PCCheck") && formCollection["PCCheck"].ToString().ToLower() == "on")) { rfq.ProcessingSection = (int)ProcessingSections.PC; } } rfq.Processing = (int)ProcessingStatus.NotProcessed; rfq.IsDeleted = false; rfq.UserID = dbuser.ID; rfq.TravelAgencyID = Convert.ToInt32((formCollection["TravelAgencySelected"].ToString()).Split(',')[0]); using (BTCEntities db = new BTCEntities()) { if (db.RFQ.Where(a => a.ProcessingSection == rfq.ProcessingSection && a.TravelRequestID == travelRequest.ID && a.TravelAgencyID == rfq.TravelAgencyID && a.IsDeleted == false).Count() < 1 && rfq.ProcessingSection != 0) { if (db.RFQ.Where(a => a.ProcessingSection == rfq.ProcessingSection && a.TravelRequestID == travelRequest.ID && a.TravelAgencyID == rfq.TravelAgencyID).Count() < 1) { rfq.RFQName = db.TravelRequests.Where(a => a.ID == travelRequest.ID).FirstOrDefault().ApplicationNumber; db.RFQ.Add(rfq); } else { RFQ rfqlist = db.RFQ.Where(a => a.ProcessingSection == rfq.ProcessingSection && a.TravelRequestID == travelRequest.ID && a.TravelAgencyID == rfq.TravelAgencyID).FirstOrDefault(); rfqlist.IsDeleted = false; db.RFQ.Attach(rfqlist); var entry = db.Entry(rfqlist); entry.Property(a => a.IsDeleted).IsModified = true; } db.SaveChanges(); } else if (rfq.ProcessingSection == 0) { ViewBag.ErrorMessage = new List <string>() { "Selet Processing Section" }; } else { ViewBag.ErrorMessage = new List <string>() { "Record already exists" }; } ViewBag.Cities = db.City.ToList(); ViewBag.Currencies = db.Currency.ToList(); ViewBag.ApprovalBy = db.Users.ToList(); ViewBag.TravelAgency = db.TravelAgency.ToList(); travelRequest = db.TravelRequests.Include(a => a.RFQ).Where(a => a.ID == rfq.TravelRequestID).FirstOrDefault(); using (EmployeeDetailsDBService EmpDBService = new EmployeeDetailsDBService("", travelRequest.Users1.HREmployeeID.ToString())) { ViewBag.FullEmployeeDetails = EmpDBService.FullEmployeeDetails(); } ViewBag.AvailableCombinations = db.RFQ.Where(a => a.TravelRequestID == rfq.TravelRequestID && a.IsDeleted == false).ToList(); return(View(travelRequest)); } }
public ActionResult CreateUser([Bind(Include = "ID,Username,FirstName,LastName,Email,Password,IsActive,ActivationCode")] Users userObj, FormCollection form) { try { bool statusRegistration = false; string messageRegistration = string.Empty; int empValue = Convert.ToInt32(form["EmployeeID"].ToString()); userObj.HREmployeeID = empValue; int DDLValue = Convert.ToInt32(form["RoleID"].ToString()); string userName = Membership.GetUserNameByEmail(userObj.Email); if (!string.IsNullOrEmpty(userName)) { ModelState.AddModelError("Warning Email", "Sorry: Email already Exists"); var errlist = ModelState.Values.Where(e => e.Errors.Count > 0).Select(a => a.Errors); List <string> sberr = new List <string>(); foreach (var item in errlist) { sberr.Add(item[0].ErrorMessage); } TempData["ErrorMessage"] = sberr.ToList(); CheckErrorMessages(); return(RedirectToAction("CreateUser", userObj)); } using (BTCEntities db = new BTCEntities()) { List <Roles> allRoles = db.Roles.ToList(); List <FullEmployeeDetail> allEmployees = new List <FullEmployeeDetail>(); using (EmployeeDetailsDBService employeeDetailsDBService = new EmployeeDetailsDBService(empCode)) { allEmployees = employeeDetailsDBService.AllEmployeeDetails(); } ViewBag.allRoles = allRoles; ViewBag.allEmployees = allEmployees; var role = db.Roles.Where(a => a.ID == DDLValue).FirstOrDefault(); var user = new Users() { Username = userObj.Username, FirstName = userObj.FirstName, LastName = userObj.LastName, Email = userObj.Email, Password = userObj.Password, HREmployeeID = userObj.HREmployeeID, ActivationCode = Guid.NewGuid(), }; user.Roles.Add(role); db.Users.Add(user); db.SaveChanges(); } //VerificationEmail(userObj.Email, userObj.ActivationCode.ToString()); messageRegistration = "Your account has been created successfully. ^_^"; statusRegistration = true; ViewBag.Message = messageRegistration; ViewBag.Status = statusRegistration; return(RedirectToAction("ManageUsers")); } catch (Exception) { return(View("CreateUser", userObj)); } }