public ActionResult Edit(int id = 0)
        {
            try
            {
                sw.Organisation organisation = swdb.Organisation.Single(o => o.Id == id);
                if (organisation == null)
                {
                    return(HttpNotFound());
                }

                OrganisationEditModel editModel = new OrganisationEditModel();
                editModel.orgTypes = new SelectList(swdb.OrganisationType, "Id", "Name", organisation.OrganisationTypeId).ToList();
                // editModel.OfficeBranch = new SelectList(db.OfficeBranch, "Id", "BranchName", organisation.BranchID).ToList();
                editModel.org = organisation;
                //editModel.accountTypes = db.AccountType.ToList();
                //editModel.SelectedAcountTypes = db.OrganisationPortfolio.Where(x => x.OrgID == organisation.Id).Select(x => x.AccountTypeID ?? 0).ToArray();

                return(View(editModel));
            }
            catch (Exception ex)
            {
                // Log with Elmah
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }
Ejemplo n.º 2
0
        public ActionResult EditOrganisation(int id)
        {
            Organisation          item         = itemMgr.GetOrganisation(id);
            OrganisationEditModel organisation = new OrganisationEditModel()
            {
                Name            = item.Name,
                FullName        = item.FullName,
                IsTrending      = item.IsTrending,
                SocialMediaLink = item.SocialMediaLink,
                ItemId          = item.ItemId
            };

            return(View(organisation));
        }
Ejemplo n.º 3
0
        public ActionResult OrganisationPartialCreate(string subplatform, OrganisationEditModel organisationEditModel)
        {
            if (ModelState.IsValid)
            {
                Subplatform Subplatform = SubplatformMgr.GetSubplatform(subplatform);
                var         iconUrl     = "";
                byte[]      image       = null;
                string      _FileName   = "";
                if (organisationEditModel.file != null)
                {
                    if (organisationEditModel.file.ContentLength > 0)
                    {
                        //_FileName = Path.GetFileName(organisationEditModel.file.FileName);
                        //var username = organisationEditModel.Name.ToString();
                        //var newName = username + "." + _FileName.Substring(_FileName.IndexOf(".") + 1);
                        //string _path = Path.Combine(Server.MapPath("~/Content/Images/Organisations/"), newName);
                        //organisationEditModel.file.SaveAs(_path);
                        //iconUrl               = @"~/Content/Images/Organisations/" + newName;
                        ImageConverter imgCon = new ImageConverter();
                        var            img    = Image.FromStream(organisationEditModel.file.InputStream);
                        image = (byte[])imgCon.ConvertTo(img, typeof(byte[]));
                    }
                }
                else
                {
                    iconUrl = Subplatform.Settings.Where(p => p.SettingName.Equals(Setting.Platform.DEFAULT_NEW_ITEM_ICON)).First().Value;
                }

                Theme theme = null;

                if (organisationEditModel.ThemeId != null)
                {
                    theme = itemMgr.GetTheme((int)organisationEditModel.ThemeId);
                    itemMgr.AddOrganisation(organisationEditModel.Name, organisationEditModel.FullName, organisationEditModel.SocialMediaLink, new List <Theme> {
                        theme
                    }, iconUrl, false, Subplatform, image);
                }
                else
                {
                    itemMgr.AddOrganisation(organisationEditModel.Name, organisationEditModel.FullName, organisationEditModel.SocialMediaLink, null, iconUrl, false, Subplatform, image);
                }

                return(RedirectToAction("ItemBeheer", "Item"));
            }

            return(RedirectToAction("ItemBeheer", "Item"));
        }
Ejemplo n.º 4
0
        public ActionResult Edit(OrganisationEditModel org)
        {
            if (ModelState.IsValid)
            {
                OrganisationDA.Save(new Organisation()
                {
                    ID               = org.ID,
                    Login            = org.Login,
                    Password         = org.Password,
                    OrganisationName = org.OrganisationName,
                    Address          = org.Address,
                    Email            = org.Email,
                    Phone            = org.Phone
                });

                return(RedirectToAction("Index"));
            }

            return(View(org));
        }
        public ActionResult Create()
        {
            try
            {
                ViewBag.OrganisationTypeId = new SelectList(swdb.OrganisationType, "Id", "Name");
                OrganisationEditModel editModel = new OrganisationEditModel();
                editModel.orgTypes = new SelectList(swdb.OrganisationType, "Id", "Name").ToList();
                //editModel.OfficeBranch = new SelectList(db.OfficeBranch, "Id", "BranchName").ToList();

                //editModel.accountTypes = db.AccountType.ToList();
                //editModel.SelectedAcountTypes = db.OrganisationPortfolio.Where(x => x.ID == -1).Select(x => x.AccountTypeID ?? 0).ToArray();

                return(View(editModel));
            }
            catch (Exception ex)
            {
                // Log with Elmah
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }
Ejemplo n.º 6
0
        public ActionResult EditOrganisation(string subplatform, int id, OrganisationEditModel organisationEditModel)
        {
            if (ModelState.IsValid)
            {
                Organisation organisation = itemMgr.GetOrganisation(organisationEditModel.ItemId);
                var          iconUrl      = "";
                byte[]       image        = null;
                string       _FileName    = "";
                if (organisationEditModel.file != null)
                {
                    if (organisationEditModel.file.ContentLength > 0)
                    {
                        //_FileName = Path.GetFileName(organisationEditModel.file.FileName);
                        //var username = organisationEditModel.Name.ToString();
                        //var newName = username + "." + _FileName.Substring(_FileName.IndexOf(".") + 1);
                        //string _path = Path.Combine(Server.MapPath("~/Content/Images/Organisations/"), newName);
                        //organisationEditModel.file.SaveAs(_path);
                        //iconUrl = @"~/Content/Images/Organisations/" + newName;
                        //organisation.IconURL = iconUrl;
                        ImageConverter imgCon = new ImageConverter();
                        var            img    = Image.FromStream(organisationEditModel.file.InputStream);
                        image = (byte[])imgCon.ConvertTo(img, typeof(byte[]));
                        organisation.Image = image;
                    }
                }
                else
                {
                    iconUrl = organisation.IconURL;
                }

                organisation.IsTrending      = organisationEditModel.IsTrending;
                organisation.FullName        = organisationEditModel.FullName;
                organisation.SocialMediaLink = organisationEditModel.SocialMediaLink;
                organisation.Name            = organisationEditModel.Name;
                itemMgr.ChangeOrganisation(organisation);
                return(RedirectToAction("ItemBeheer", "Item"));
            }
            return(RedirectToAction("ItemBeheer", "Item"));
        }
        public ActionResult Edit(OrganisationEditModel editModel)
        {
            try
            {
                sw.Organisation organisation = editModel.org;
                if (ModelState.IsValid)
                {
                    if (String.IsNullOrEmpty(organisation.RegNumber))
                    {
                        var applNoResp = generateEmployerNumber(organisation.Name, organisation.CommencementDate ?? DateTime.Now);
                        if (applNoResp.Key == true)
                        {
                            organisation.RegNumber = applNoResp.Value;
                        }
                    }


                    organisation.ModifiedBy   = User.Identity.Name;
                    organisation.ModifiedDate = DateTime.Now;
                    swdb.Organisation.Attach(organisation);
                    swdb.Entry(organisation).State = EntityState.Modified;
                    // swdb.ObjectStateManager.ChangeObjectState(organisation, EntityState.Modified);
                    swdb.SaveChanges();



                    if (membershipService.GetUser(organisation.RegNumber) == null)
                    {
                        MembershipUser newUser;
                        //MembershipCreateStatus status;
                        newUser = membershipService.CreateUser(organisation.RegNumber, organisation.RegNumber, organisation.ContactEmailAddress);

                        roleService.AddUserToRole(organisation.RegNumber, "Organisation Admin");

                        sw.Users user = swdb.Users.Where(x => x.UserName == organisation.RegNumber).FirstOrDefault();
                        organisation.Users.Add(user);
                        swdb.SaveChanges();
                    }


                    //int[] acnts = editModel.SelectedAcountTypes;

                    //if (acnts != null)
                    //{
                    //    foreach (int account in acnts)
                    //    {
                    //        OrganisationPortfolio orgPort = db.OrganisationPortfolio.Where(x => x.OrgID == organisation.Id && x.AccountTypeID == account).FirstOrDefault();
                    //        if (orgPort == null)
                    //        {
                    //            OrganisationPortfolio detail = new OrganisationPortfolio();
                    //            detail.AccountTypeID = account;
                    //            detail.OrgID = organisation.Id;
                    //            detail.AccountState = 1;
                    //            detail.LastPayment = DateTime.Now;
                    //            detail.ModifiedBy = User.Identity.Name;
                    //            detail.ModifiedDate = DateTime.Now;
                    //            detail.TotalPayments = 0;
                    //            detail.TotalOverPaid = 0;
                    //            detail.TotalPenalty = 0;
                    //            db.OrganisationPortfolio.AddObject(detail);
                    //            db.SaveChanges();
                    //        }
                    //    }
                    //}



                    TempData["message"] = "<b>" + organisation.Name + "</b> was Successfully Updated";
                    return(RedirectToAction("Index"));
                }
                editModel.orgTypes = new SelectList(swdb.OrganisationType, "Id", "Name", organisation.OrganisationTypeId).ToList();
                //editModel.OfficeBranch = new SelectList(db.OfficeBranch, "Id", "BranchName", organisation.BranchID).ToList();
                //editModel.accountTypes = db.AccountType.ToList();
                //editModel.SelectedAcountTypes = db.OrganisationPortfolio.Where(x => x.OrgID == organisation.Id).Select(x => x.AccountTypeID ?? 0).ToArray();

                return(View(editModel));
            }
            catch (Exception ex)
            {
                // Log with Elmah
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }