public ActionResult Index(int?id, int view = 0)
        {
            ViewBag.Organizations = organizationService.GetAll().Where(x => x.IsActive).ToList();
            ViewBag.Designations  = designationService.GetAll().Where(x => x.IsActive).ToList();
            ViewBag.Departments   = departmentService.GetAll().Where(x => x.IsActive).ToList();
            ViewBag.Genders       = genderService.GetAll().Where(x => x.IsActive).ToList();
            ViewBag.Divisions     = divisionService.GetAll().Where(x => x.IsActive).ToList();
            ViewBag.Districts     = districtService.GetAll().Where(x => x.IsActive).ToList();
            ViewBag.Thanas        = thanaService.GetAll().Where(x => x.IsActive).ToList();
            ViewBag.Countries     = countryService.GetAll().Where(x => x.IsActive).ToList();
            ViewBag.TeamList      = teamService.GetAll().ToList();
            var executives = officeExecutiveService.GetAll().Where(x => x.IsActive).ToList();

            ViewBag.ExecutiveList = executives;
            var executive = new OfficeExecutive()
            {
                Id = 0
            };

            if (id.HasValue)
            {
                executive = executives.FirstOrDefault(x => x.Id == id);
            }
            ViewBag.Executive  = executive;
            ViewBag.IsViewMode = view;
            return(View());
        }
        public JsonResult ExecutiveSetup(OfficeExecutive executive, HttpPostedFileBase photo, HttpPostedFileBase sign, string joiningDate)
        {
            executive.PresentThanaId   = executive.PresentThanaId == 0 ? null : executive.PresentThanaId;
            executive.PermanentThanaId = executive.PermanentThanaId == 0 ? null : executive.PermanentThanaId;
            executive.TeamId           = executive.TeamId == 0 ? null : executive.TeamId;

            var joining = ReportHelper.FormatDate(joiningDate);

            executive.JoiningDate = joining;
            if (executive.Id == 0)
            {
                executive.EntryUserId = SessionHelper.LoggedInUserId;
                executive.EntryDate   = DateTime.Now;
                executive.IsActive    = true;
                if (photo != null)
                {
                    executive.Photograph = ReportHelper.ConvertStreamToByte(photo.InputStream);
                }
                if (sign != null)
                {
                    executive.Signature = ReportHelper.ConvertStreamToByte(sign.InputStream);
                }

                if (
                    officeExecutiveService.GetAll()
                    .FirstOrDefault(x => x.ExecutiveCode.ToLower() == executive.ExecutiveCode.ToLower()) != null)
                {
                    return(Json(new { Status = false, Message = "Duplicate executive code." }, JsonRequestBehavior.AllowGet));
                }

                officeExecutiveService.Create(executive);
                return(Json(new { Status = true, Message = "New executive created successfully." },
                            JsonRequestBehavior.AllowGet));
            }
            var existExecutive = officeExecutiveService.GetById(executive.Id);

            existExecutive.ExecutiveName    = executive.ExecutiveName;
            existExecutive.ExecutiveCode    = executive.ExecutiveCode;
            existExecutive.OrganizationId   = executive.OrganizationId;
            existExecutive.DesignationId    = executive.DesignationId;
            existExecutive.DepartmentId     = executive.DepartmentId;
            existExecutive.JoiningDate      = executive.JoiningDate;
            existExecutive.FatherName       = executive.FatherName;
            existExecutive.MotherName       = executive.MotherName;
            existExecutive.GenderId         = executive.GenderId;
            existExecutive.PresentAddress   = executive.PresentAddress;
            existExecutive.PresentThanaId   = executive.PresentThanaId;
            existExecutive.PermanentAddress = executive.PermanentAddress;
            existExecutive.PermanentThanaId = executive.PermanentThanaId;
            existExecutive.CountryId        = executive.CountryId;
            existExecutive.Email            = executive.Email;
            existExecutive.Mobile           = executive.Mobile;
            existExecutive.TeamId           = executive.TeamId;
            if (photo != null)
            {
                existExecutive.Photograph = ReportHelper.ConvertStreamToByte(photo.InputStream);
            }
            if (sign != null)
            {
                existExecutive.Signature = ReportHelper.ConvertStreamToByte(sign.InputStream);
            }
            existExecutive.UpdateUserId = SessionHelper.LoggedInUserId;
            existExecutive.UpdateDate   = DateTime.Now;

            if (
                officeExecutiveService.GetAll()
                .FirstOrDefault(x => x.ExecutiveCode.ToLower() == executive.ExecutiveCode.ToLower() && x.Id != executive.Id) !=
                null)
            {
                return(Json(new { Status = false, Message = "Duplicate executive code." }, JsonRequestBehavior.AllowGet));
            }

            officeExecutiveService.Update(existExecutive);
            return(Json(new { Status = true, Message = "Executive updated successfully." },
                        JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
 public void Update(OfficeExecutive objectToUpdate)
 {
     repository.Update(objectToUpdate);
     Save();
 }
Esempio n. 4
0
 public OfficeExecutive Create(OfficeExecutive objectToCreate)
 {
     repository.Add(objectToCreate);
     Save();
     return(objectToCreate);
 }