Ejemplo n.º 1
0
        public bool DeleteVisitor(VisitorDetailsVM visitorDetailsVM)
        {
            var visitorFromDb = _genericService
                                .VisitorMaster.GetAll().Where(item => item.Id == visitorDetailsVM.Id).FirstOrDefault();

            if (visitorFromDb != null)
            {
                _genericService.VisitorMaster.Delete(visitorFromDb);
                _genericService.Commit();
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
 public ReturnResult DeleteVisitor([FromBody] VisitorDetailsVM visitorVM)
 {
     try
     {
         var result = _visitorHelper.DeleteVisitor(visitorVM);
         return(new ReturnResult {
             Message = (result == true ? "Success" : "Failure"), Success = (result == true ? true : false)
         });
     }
     catch (Exception ex)
     {
         return(new ReturnResult {
             Message = "Failure", Success = false
         });
     }
     return(null);
 }
Ejemplo n.º 3
0
        public ReturnResult SaveVisitor([FromBody] VisitorDetailsVM visitorDetailsVM)
        {
            var message = "";
            var result  = false;

            if (visitorDetailsVM.IsInsert)
            {
                message = _visitorHelper.IsVisitorEmailExist(visitorDetailsVM);
            }

            if (string.IsNullOrEmpty(message))
            {
                result = _visitorHelper.SaveVisitor(visitorDetailsVM);
                return(new ReturnResult {
                    Message = "Success", Success = true
                });
            }

            return(new ReturnResult {
                Message = message, Success = false
            });
        }
Ejemplo n.º 4
0
        public string IsVisitorEmailExist(VisitorDetailsVM visitorDetailsVM)
        {
            var visitors =
                _genericService.VisitorMaster.GetAll();

            if (visitorDetailsVM.EmailAddress != "" && visitorDetailsVM.EmailAddress != null)
            {
                if (visitors.Where(item => item.EmailId == visitorDetailsVM.EmailAddress).FirstOrDefault() != null)
                {
                    return("Email already exist");
                }
            }
            else if (visitors.Where(item => item.EmailId == visitorDetailsVM.ContactNo).FirstOrDefault() != null)
            {
                return("Contact Number already exist");
            }
            else if (visitors.Where(item => item.EmailId == visitorDetailsVM.IdNo).FirstOrDefault() != null)
            {
                return("Identity provided already exist");
            }
            return(string.Empty);
        }
Ejemplo n.º 5
0
        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);
        }