public ActionResult Create([Bind(Include = "Id,Name,Code,RegNo")] OrganizationViewModel organizationViewModel)
        {
            if (ModelState.IsValid)
            {
                Organization organization = Mapper.Map <Organization>(organizationViewModel);

                var name  = organization.Name.Trim();
                var code  = organization.Code.Trim();
                var regNo = organization.RegNo.Trim();

                if (_organizationManager.GetAll().Count(o => o.Name == name) > 0)
                {
                    ViewBag.Message1 = "Organization name already exist.";
                }
                if (_organizationManager.GetAll().Count(o => o.Code == code) > 0)
                {
                    ViewBag.Message2 = "Organization code already exist.";
                }
                if (_organizationManager.GetAll().Count(o => o.RegNo == regNo) > 0)
                {
                    ViewBag.Message3 = "Organization registration no already exist.";
                }
                if (ViewBag.Message1 == null && ViewBag.Message2 == null && ViewBag.Message3 == null)
                {
                    _organizationManager.Add(organization);

                    TempData["msg"] = "Information has been save successfully";
                    return(RedirectToAction("Index"));
                }
            }

            return(View(organizationViewModel));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "Id,Name")] OrganizationViewModel organizationViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Organization organization = Mapper.Map <Organization>(organizationViewModel);

                    var name = organization.Name.Trim();

                    if (_organizationManager.GetAll().Count(o => o.Name == name) > 0)
                    {
                        ViewBag.Message1 = "Organization name already exist.";
                    }
                    if (ViewBag.Message1 == null)
                    {
                        _organizationManager.Add(organization);

                        TempData["msg"] = "Information has been save successfully";
                        return(RedirectToAction("Index"));
                    }
                }

                return(View(organizationViewModel));
            }
            catch (Exception ex)
            {
                ExceptionMessage(ex);
                return(View("Error", new HandleErrorInfo(ex, "Organizations", "Create")));
            }
        }
Beispiel #3
0
        public ActionResult Entry(Organization organization)
        {
            var isAdded = _manager.Add(organization);

            if (isAdded)
            {
                ViewBag.SuccessMessage = "Organization Created Successfully";
            }

            ViewBag.ErrorMessage = "Organization Creation Failed";

            return(RedirectToAction("Entry", "Organization"));
        }
        public ActionResult Create([Bind(Include = "OrganizationID,OrganizationName,OrganizationShortName,OrganizationLocation")] Organization organization)
        {
            if (Session["LogedUserID"] != null)
            {
                if (ModelState.IsValid)
                {
                    //db.Organizations.Add(organization);
                    //db.SaveChanges();
                    _organizationManager.Add(organization);
                    return(RedirectToAction("Index"));
                }

                return(View(organization));
            }
            return(RedirectToAction("Login", "Admin"));
        }
Beispiel #5
0
        public ActionResult Create([Bind(Include = "Id,Name,ShortName,Location,Description")] Organization organization)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _organizationManager.Add(organization);
                } catch (Exception ex)
                {
                    ModelState.AddModelError("ShortName", ex.Message);
                    return(View());
                }

                return(RedirectToAction("Index"));
            }

            return(View(organization));
        }
Beispiel #6
0
        public ActionResult Create(Organization organization)
        {
            var list = organizationManager.GetSome(5);

            ViewBag.olist = list.ToList();

            if (organizationManager.IsExist(organization.Code))
            {
                ViewData["exist"] = "Code Already Exist";
            }
            else
            {
                organizationManager.Add(organization);
                ModelState.Clear();
                return(RedirectToAction("Create", new { success = "true" }));
            }
            return(View(organization));
        }
Beispiel #7
0
        public ActionResult Create(Organization organization)
        {
            //PartialMenuView();

            if (ModelState.IsValid && organization != null)
            {
                ModelState.Clear();

                try
                {
                    if (_manager.Add(organization))
                    {
                        ViewBag.Msg = "Created successfully!";
                        return(View());
                    }
                }
                catch (Exception exception)
                {
                    int NameExist = _manager.GetAll(c => c.Name.Equals(organization.Name)).Count();

                    if (NameExist > 0)
                    {
                        organization.Name = null;
                        ModelState.AddModelError("Name", "Organization name already exists");
                    }

                    int ShortNameExits = _manager.GetAll(c => c.ShortName == organization.ShortName).Count();

                    if (ShortNameExits > 0)
                    {
                        organization.ShortName = null;
                        ModelState.AddModelError("ShortName", "Short name already exists");
                    }
                }
            }

            return(View(organization));
        }