Example #1
0
        public ActionResult Index(OrganizationCreateForView model, HttpPostedFileBase Logo)
        {
            var organization = Mapper.Map <Organization>(model);

            if (_organizationBll.GetAll().Any(e => e.Name == model.Name))
            {
                ModelState.AddModelError("Name", "This Organization Is Already Assign");
            }

            if (ModelState.IsValid)
            {
                string fileName  = Path.GetFileName(Logo.FileName);
                string extention = Path.GetExtension(Logo.FileName);
                fileName          = fileName + DateTime.Now.ToString("yymmssfff") + extention;
                organization.Logo = "~/Image/" + fileName;
                string filePath = Path.Combine(Server.MapPath("~/Image/"), fileName);
                Logo.SaveAs(filePath);

                var isAdded = _organizationBll.Add(organization);

                return(RedirectToAction("Details", new { id = organization.Id }));
            }


            return(View(model));
        }