public ActionResult CompanyDetailsEdit(long Id)
        {
            CompanyDetailsFormModel companydetails = new CompanyDetailsFormModel();

            CompanyDetails companyDets = companyDetailsService.GetCompanyDetails(Id);

            if (companyDets != null)
                companydetails = AutoMapper.Mapper.Map<CompanyDetailsFormModel>(companyDets);

            return View("CompanyDetailsEdit", companydetails);
        }
        public ActionResult CompanyDetails()
        {
            CompanyDetailsFormModel companydetails = new CompanyDetailsFormModel();

            CompanyDetails companyDets = companyDetailsService.GetCompanyDetails().FirstOrDefault();

            if (companyDets != null)
            {
                companydetails = AutoMapper.Mapper.Map<CompanyDetailsFormModel>(companyDets);

                if (companydetails.CompanyLogo != null)
                    companydetails.CompanyLogoPath = "~/Content/Company/" + companydetails.CompanyLogo;
            }

            return View("CompanyDetails", companydetails);
        }
        public ActionResult CompanyDetailsEdit(CompanyDetailsFormModel companyDetails)
        {
            try
            {
                CompanyDetails companyDets = AutoMapper.Mapper.Map<CompanyDetails>(companyDetails);

                if (ModelState.IsValid)
                {
                    HttpPostedFileBase file = companyDetails.ImageUpload;

                    if (file != null)
                    {
                        if (file.ContentLength > 0)
                        {
                            int MaxContentLength = 1024 * 1024 * 3; //3 MB

                            string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png" };

                            if (!AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.'))))
                            {
                                ModelState.AddModelError("LogoImageUpload", "Please file of type: " + string.Join(", ", AllowedFileExtensions));
                            }
                            else if (file.ContentLength > MaxContentLength)
                            {
                                ModelState.AddModelError("LogoImageUpload", "File is too large, maximum allowed size is: " + MaxContentLength + " MB");
                            }
                            else
                            {
                                //TO:DO
                                var fileName = Path.GetFileName(file.FileName);
                                var path = Path.Combine(Server.MapPath("~/Content/Company"), fileName);
                                file.SaveAs(path);
                                companyDets.CompanyLogo = fileName;
                                companyDetails.CompanyLogo = fileName;
                                companyDetails.CompanyLogoPath = path;
                            }
                        }
                    }

                    if (companyDets.ID != 0)
                        companyDetailsService.CreateCompanyDetails(companyDets);
                    else
                        companyDetailsService.EditCompanyDetails(companyDets);

                    ViewBag.successMessage = "CompanyDetails Saved Successfully";
                    ViewBag.errorMessage = "";
                }
                else
                {
                    string validationErrors = string.Join(",", ModelState.Values.Where(E => E.Errors.Count > 0)
                    .SelectMany(E => E.Errors).Select(E => E.ErrorMessage).ToArray());

                    ViewBag.successMessage = "";
                    ViewBag.errorMessage = validationErrors;
                }
            }
            catch (Exception ex)
            {
                ViewBag.successMessage = "";
                ViewBag.errorMessage = string.Format("Error in CompanyDetails Save : {0}", ex.Message);
            }

            return View("CompanyDetailsEdit", companyDetails);
        }