public EmployeeContactViewModel returnEmergencyContactList(int Id)
        {
            EmployeeContactViewModel model = new EmployeeContactViewModel();

            model.Id = Id;
            var data = _db.Employe_EmergencyContacts.Where(x => x.EmployeeID == Id && x.Archived == false).ToList();

            if (data.Count > 0)
            {
                foreach (var item in data)
                {
                    var value = _otherSettingMethod.getSystemListValueById(item.Relationship);
                    EmergencyContactsViewModel dd = new EmergencyContactsViewModel();
                    dd.Id         = item.Id;
                    dd.Name       = item.Name;
                    dd.EmployeeId = item.EmployeeID;
                    if (value != null)
                    {
                        dd.RelationshipValue = value.Value;
                    }
                    dd.Telephone = item.Telephone;
                    model.EmergencyContactsList.Add(dd);
                }
            }
            return(model);
        }
        public ActionResult SaveEmergencyContacts(EmergencyContactsViewModel model)
        {
            _EmployeeContactMethod.saveEmergencyContact(model, SessionProxy.UserId);

            //  EmployeeContactViewModel Model = returnEmergencyContactList(model.EmployeeId);
            // return PartialView("_partialEmergencyContactList", Model);
            EmployeeContactViewModel models = _EmployeeContactMethod.employeeDetailsById(model.EmployeeId);

            return(PartialView("_PartialEmployeeContactsRecord", models));
        }
        public ActionResult AddEditEmergencyContacts(int Id, int EmployeeID)
        {
            EmergencyContactsViewModel model = new EmergencyContactsViewModel();

            model.Id         = Id;
            model.EmployeeId = EmployeeID;
            model.RelationshipList.Add(new SelectListItem()
            {
                Text = "-- Select Relationship --", Value = "0"
            });
            foreach (var item in _otherSettingMethod.getAllSystemValueListByKeyName("Relationship List"))
            {
                model.RelationshipList.Add(new SelectListItem()
                {
                    Text = item.Value, Value = item.Id.ToString()
                });
            }

            if (Id > 0)
            {
                var data = _EmployeeContactMethod.getEmergencyContactById(Id);

                model.Id           = data.Id;
                model.EmployeeId   = data.EmployeeID;
                model.Name         = data.Name;
                model.Relationship = data.Relationship;
                if (data.Relationship > 0)
                {
                    var relationship = _otherSettingMethod.getSystemListValueById(data.Relationship);
                    if (relationship != null)
                    {
                        model.RelationshipValue = relationship.Value;
                    }
                }
                model.Postcode  = data.PostCode;
                model.Address   = data.Address;
                model.Mobile    = data.Mobile;
                model.Telephone = data.Telephone;
                model.Mobile    = data.Mobile;
                model.Comments  = data.Comments;
            }

            return(PartialView("_partialAddEditEmergencyContact", model));
        }
 public void saveEmergencyContact(EmergencyContactsViewModel model, int userId)
 {
     if (model.Id > 0)
     {
         Employe_EmergencyContacts data = _db.Employe_EmergencyContacts.Where(x => x.Id == model.Id).FirstOrDefault();
         data.EmployeeID           = model.EmployeeId;
         data.Name                 = model.Name;
         data.Relationship         = model.Relationship;
         data.PostCode             = model.Postcode;
         data.Address              = model.Address;
         data.Telephone            = model.Telephone;
         data.Mobile               = model.Mobile;
         data.Comments             = model.Comments;
         data.UserIDLastModifiedBy = userId;
         data.LastModified         = DateTime.Now;
         _db.SaveChanges();
     }
     else
     {
         Employe_EmergencyContacts data = new Employe_EmergencyContacts();
         data.EmployeeID           = model.EmployeeId;
         data.Name                 = model.Name;
         data.Relationship         = model.Relationship;
         data.PostCode             = model.Postcode;
         data.Address              = model.Address;
         data.Telephone            = model.Telephone;
         data.Mobile               = model.Mobile;
         data.Comments             = model.Comments;
         data.Archived             = false;
         data.UserIDCreatedBy      = userId;
         data.CreatedDate          = DateTime.Now;
         data.UserIDLastModifiedBy = userId;
         data.LastModified         = DateTime.Now;
         _db.Employe_EmergencyContacts.Add(data);
         _db.SaveChanges();
     }
 }