public bool SaveVisitorCheckIn(VisitorCheckInVM visitorCheckInVM, string userId) { var gate = _genericService.ShitfAssignment.GetAll().Where(item => item.UserId == userId && item.IsActive).FirstOrDefault(); if (gate != null) { VisitDetails _visitDetails = new VisitDetails(); _visitDetails.VisitorId = visitorCheckInVM.VisitorId; _visitDetails.ContactPerson = visitorCheckInVM.ContactPerson; _visitDetails.NoOfPerson = visitorCheckInVM.NoOfPerson; _visitDetails.PurposeOfVisit = visitorCheckInVM.PurposeOfVisit; _visitDetails.CheckIn = DateTime.UtcNow; _visitDetails.CheckOut = null; _visitDetails.CreatedBy = visitorCheckInVM.CreatedBy; _visitDetails.CheckInGate = gate.GateId; _visitDetails.CheckOutGate = gate.GateId; _visitDetails.CompanyName = visitorCheckInVM.CompanyName; _visitDetails.VahicleNumber = visitorCheckInVM.VahicleNumber; _visitDetails.Floor = visitorCheckInVM.Floor; _genericService.VisitDetails.Insert(_visitDetails); _genericService.Commit(); return(true); } return(false); }
public ReturnResult ApplyShiftAssignmentChanges(IList <ShiftAssignmentChanges> request) { var returnResult = new ReturnResult(); request.ToList().ForEach(item => { if (item.IsAssigned) { var shiftAssignmentChange = new ShiftDetails { Id = 0, IsActive = true, GateID = item.GateId, ShiftDate = item.ShiftDate, ShiftID = item.ShiftId, SecurityID = item.UserId }; _genericService.ShiftDetails.Insert(shiftAssignmentChange); } else { var shiftAssignmentChange = _genericService.ShiftDetails.GetAll() .FirstOrDefault(item_db => item_db.ShiftID == item.ShiftId && item_db.SecurityID == item.UserId && item_db.ShiftDate == item.ShiftDate && item_db.IsActive ); var shiftAssignmentChangeLst = _genericService.ShiftDetails.GetAll() .Where(item_db => item_db.ShiftID == item.ShiftId && item_db.SecurityID == item.UserId && item_db.IsActive ); if (shiftAssignmentChangeLst != null) { if (shiftAssignmentChangeLst.Count() == 1) { var shiftAssignmentObj = _genericService.ShitfAssignment.GetAll().FirstOrDefault(item_db => item_db.ShitfId == shiftAssignmentChange.ShiftID && item_db.UserId == shiftAssignmentChange.SecurityID && item_db.IsActive); if (shiftAssignmentObj != null) { shiftAssignmentObj.IsActive = false; _genericService.ShitfAssignment.Update(shiftAssignmentObj); } } } if (shiftAssignmentChange != null) { shiftAssignmentChange.IsActive = false; _genericService.ShiftDetails.Update(shiftAssignmentChange); } } }); _genericService.Commit(); returnResult.Success = true; return(returnResult); }
public bool SaveVisitor(VisitorDetailsVM visitorDetailsVM) { var userId = System.Web.HttpContext.Current.User.Identity.GetUserId(); if (visitorDetailsVM.IsInsert) { _genericService .VisitorMaster.Insert(new Data.Model.Entities.VisitorMaster { ContactNo = visitorDetailsVM.ContactNo, CreatedBy = userId, CreatedDate = DateTime.UtcNow, DOB = visitorDetailsVM.DOB, EmailId = visitorDetailsVM.EmailAddress, VisitorName = visitorDetailsVM.VisitorName, Nationality = visitorDetailsVM.Nationality, UpdatedBy = userId, UpdatedDate = DateTime.Now, GenderId = visitorDetailsVM.Gender, TypeOfCardId = visitorDetailsVM.TypeOfCard, IdNo = visitorDetailsVM.IdNo, Address = visitorDetailsVM.ContactAddress, ProfilePicPath = visitorDetailsVM.ImagePath, // IdentityImage1_Path = (visitorDetailsVM.IdentityImage1_Path == "VisitorImage" ? null : visitorDetailsVM.IdentityImage1_Path), IdentityImage1_Path = visitorDetailsVM.IdentityImage1_Path, IdentityImage2_Path = visitorDetailsVM.IdentityImage2_Path, IdentityImage3_Path = visitorDetailsVM.IdentityImage3_Path, CompanyName = visitorDetailsVM.CompanyName }); _genericService.Commit(); } else { var visitor = _genericService.VisitorMaster.GetAll() .Where(item => item.Id == visitorDetailsVM.Id) .FirstOrDefault(); if (visitor != null) { visitor.ContactNo = visitorDetailsVM.ContactNo; visitor.DOB = visitorDetailsVM.DOB; visitor.EmailId = visitorDetailsVM.EmailAddress; visitor.VisitorName = visitorDetailsVM.VisitorName; visitor.Nationality = visitorDetailsVM.Nationality; visitor.GenderId = visitorDetailsVM.Gender; visitor.TypeOfCardId = visitorDetailsVM.TypeOfCard; visitor.IdNo = visitorDetailsVM.IdNo; visitor.Address = visitorDetailsVM.ContactAddress; visitor.UpdatedBy = userId; visitor.UpdatedDate = DateTime.Now; visitor.ProfilePicPath = visitorDetailsVM.ImagePath; visitor.IdentityImage1_Path = visitorDetailsVM.IdentityImage1_Path; visitor.IdentityImage2_Path = visitorDetailsVM.IdentityImage2_Path; visitor.IdentityImage3_Path = visitorDetailsVM.IdentityImage3_Path; visitor.CompanyName = visitorDetailsVM.CompanyName; _genericService.VisitorMaster.Update(visitor); _genericService.Commit(); } } return(true); }
public async Task <ActionResult> SaveUploadedFile() { bool isSavedSuccessfully = true; string userId = System.Web.HttpContext.Current.User.Identity.GetUserId(); //string userId = HttpContext.Current.User.Identity.GetUserId(); var currentUser = await _userService.GetAsync(x => x.Id == userId); // var result = _genericService.Organization.GetAll().FirstOrDefault(item => item.Id == currentUser.OrganizationId); string orginization = string.Empty; string logoPath = string.Empty; string imageLocation = string.Empty; if (currentUser.Organization == null)// in case of super admin only { imageLocation = "\\images\\logo\\main_logo.png"; logoPath = string.Format("{0}\\images\\logo\\main_logo.png", Server.MapPath(@"\")); } else { orginization = currentUser.Organization.CompanyName; imageLocation = "\\images\\logo\\" + orginization + "\\logo.png"; logoPath = string.Format("{0}images\\logo\\" + orginization, Server.MapPath(@"\")); } var existingOrg = _genericService.Organization.GetById(currentUser.Organization.Id); existingOrg.ImagePath = imageLocation; _genericService.Organization.Update(existingOrg); string fName = ""; try { foreach (string fileName in Request.Files) { HttpPostedFileBase file = Request.Files[fileName]; fName = string.Format("{0}_{1}", fileName, file.FileName); if (file != null && file.ContentLength > 0) { var originalDirectory = new DirectoryInfo(logoPath); string fileWithPath = System.IO.Path.Combine(originalDirectory.ToString(), "logo.png"); var fileName1 = Path.GetFileName(fName); bool isfolderExists = System.IO.Directory.Exists(originalDirectory.ToString()); bool isExists = System.IO.File.Exists(fileWithPath); if (!isfolderExists) { System.IO.Directory.CreateDirectory(originalDirectory.ToString()); } if (isExists) { System.IO.File.Delete(fileWithPath); } file.SaveAs(fileWithPath); } } } catch (Exception ex) { isSavedSuccessfully = false; } //return View(); if (Request.Files.Count > 0) { if (isSavedSuccessfully) { _genericService.Commit(); return(Json(new { Message = fName, ImagePath = imageLocation })); } else { return(Json(new { Message = "Error in saving file", ImagePath = imageLocation })); } } return(Json(new { Message = "No file to upload", ImagePath = imageLocation })); }