Ejemplo n.º 1
0
        public ActionResult Create(int orgID)
        {
            try
            {
                OrganisationContactModel editModel = new OrganisationContactModel();
                sw.Organisation          member    = swdb.Organisation.Where(x => x.Id == orgID).FirstOrDefault();

                if (member == null)
                {
                    return(HttpNotFound());
                }

                sw.ContactInfo memberBeneficiary = new sw.ContactInfo()
                {
                    OrgID = member.Id
                };
                editModel.org         = member;
                editModel.contactInfo = memberBeneficiary;
                //editModel.addressType = new SelectList(swdb.AddressType, "ID", "Name").ToList();

                return(View(editModel));
            }
            catch (Exception ex)
            {
                // Log with Elmah
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", new { orgID = orgID }));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Edit(OrganisationContactModel editModel)
        {
            sw.ContactInfo memberBeneficiary = editModel.contactInfo;
            try
            {
                if (ModelState.IsValid)
                {
                    memberBeneficiary.ModifiedBy   = User.Identity.Name;
                    memberBeneficiary.ModifiedDate = DateTime.Now;

                    swdb.ContactInfo.Attach(memberBeneficiary);
                    swdb.Entry(memberBeneficiary).State = EntityState.Modified;
                    //swdb.ObjectStateManager.ChangeObjectState(memberBeneficiary, EntityState.Modified);


                    swdb.SaveChanges();
                    TempData["message"] = "<b>" + memberBeneficiary.FirstName + "</b> was Successfully Updated";
                    return(RedirectToAction("Index", new { orgID = memberBeneficiary.OrgID }));
                }

                //  editModel.addressType = new SelectList(swdb.AddressType, "ID", "Name", memberBeneficiary.AddressTypeId).ToList();

                return(View(editModel));
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", new { orgID = memberBeneficiary.OrgID }));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Edit(int ID)
        {
            try
            {
                OrganisationContactModel editModel         = new OrganisationContactModel();
                sw.ContactInfo           memberBeneficiary = swdb.ContactInfo.Where(x => x.Id == ID).FirstOrDefault();

                if (memberBeneficiary == null)
                {
                    return(HttpNotFound());
                }

                sw.Organisation member = swdb.Organisation.Where(x => x.Id == memberBeneficiary.OrgID).FirstOrDefault();

                editModel.org         = member;
                editModel.contactInfo = memberBeneficiary;

                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.º 4
0
        public ActionResult Create(OrganisationContactModel editModel)
        {
            sw.ContactInfo memberBeneficiary = editModel.contactInfo;
            try
            {
                if (ModelState.IsValid)
                {
                    memberBeneficiary.ModifiedBy   = User.Identity.Name;
                    memberBeneficiary.ModifiedDate = DateTime.Now;
                    swdb.ContactInfo.Add(memberBeneficiary);

                    swdb.SaveChanges();
                    TempData["message"] = "<b>" + memberBeneficiary.FirstName + "</b> was Successfully Saved";
                    return(RedirectToAction("Index", new { orgID = memberBeneficiary.OrgID }));
                }
                sw.Organisation member = swdb.Organisation.Where(x => x.Id == editModel.contactInfo.OrgID).FirstOrDefault();
                editModel.org = member;
                //editModel.addressType = new SelectList(swdb.AddressType, "ID", "Name").ToList();
                return(View(editModel));
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", new { orgID = memberBeneficiary.OrgID }));
            }
        }
        public static void InsertRecord(OrganisationContactModel organisationContact)
        {
            var sql =
                "INSERT INTO [dbo].[Contacts] ([Id],[DisplayName],[Email],[EndPointAssessorOrganisationId] ,[OrganisationId],[Status] ,[Username],[PhoneNumber], [CreatedAt])" +
                " VALUES (@Id, @DisplayName, @Email, @EndPointAssessorOrganisationId, @organisationId, @Status, @Username, @PhoneNumber, getutcdate()); ";

            DatabaseService.Execute(sql, organisationContact);
        }
Ejemplo n.º 6
0
        public ActionResult Index([DefaultValue(1)] int page, string keywords, [DefaultValue(12)] int pgsize, int orgID)
        {
            try
            {
                //var organisation = db.Organisation.Include("OrganisationType");
                //return View(organisation.ToList());

                sw.Organisation member = swdb.Organisation.Where(x => x.Id == orgID).FirstOrDefault();
                if (member == null)
                {
                    TempData["message"] = Settings.Default.GenericExceptionMessage;
                    return(RedirectToAction("Index", "Home"));
                }

                List <sw.ContactInfo> rowsToShow = new List <sw.ContactInfo>();
                int totalRecords = 0;


                if (!string.IsNullOrEmpty(keywords))
                {
                    rowsToShow = swdb.ContactInfo.Where(x => x.OrgID == orgID && (x.FirstName.ToUpper().Contains(keywords.Trim().ToUpper()) || x.LastName.ToUpper().Contains(keywords.Trim().ToUpper()))).OrderBy(x => x.Id).Skip((page - 1) * pgsize).Take(pgsize).ToList();

                    totalRecords = swdb.ContactInfo.Where(x => x.OrgID == orgID && (x.FirstName.ToUpper().Contains(keywords.Trim().ToUpper()) || x.LastName.ToUpper().Contains(keywords.Trim().ToUpper()))).Count();
                }
                else
                {
                    rowsToShow   = swdb.ContactInfo.Where(x => x.OrgID == orgID).OrderBy(x => x.Id).Skip((page - 1) * pgsize).Take(pgsize).ToList();
                    totalRecords = swdb.ContactInfo.Where(x => x.OrgID == orgID).Count();
                }


                OrganisationContactModel model = new OrganisationContactModel()
                {
                    Rows       = rowsToShow,
                    org        = member,
                    PagingInfo = new PagingInfo
                    {
                        FirstItem    = ((page - 1) * pgsize) + 1,
                        LastItem     = page * pgsize,
                        CurrentPage  = page,
                        ItemsPerPage = pgsize,
                        TotalItems   = totalRecords
                    },
                    CurrentKeywords = keywords,
                    PageSize        = pgsize
                };
                return(View(model));
            }
            catch (Exception ex)
            {
                // Log with Elmah
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["message"] = Settings.Default.GenericExceptionMessage;
                return(RedirectToAction("Index", "Home", new { area = "Admin" }));
            }
        }
        public void SetUpOrganisationTests()
        {
            _repository            = new RegisterRepository(_databaseService.WebConfiguration, new Mock <ILogger <RegisterRepository> >().Object);
            _validationRepository  = new RegisterValidationRepository(_databaseService.WebConfiguration);
            _organisationIdCreated = "EPA0987";
            _organisationTypeId    = 5;
            OrganisationTypeHandler.InsertRecord(new OrganisationTypeModel {
                Id = _organisationTypeId, Status = "new", Type = "organisation type 1"
            });
            _id = Guid.NewGuid();

            _organisation = new OrganisationModel
            {
                Id                             = _id,
                CreatedAt                      = DateTime.Now,
                EndPointAssessorName           = "name 2",
                EndPointAssessorOrganisationId = _organisationIdCreated,
                PrimaryContact                 = null,
                OrganisationTypeId             = _organisationTypeId,
                OrganisationData               = null,
                Status                         = OrganisationStatus.New
            };

            _username = "******";
            OrganisationHandler.InsertRecord(_organisation);
            _contactId    = Guid.NewGuid();
            _contactModel = new OrganisationContactModel
            {
                Id = _contactId,
                EndPointAssessorOrganisationId = _organisationIdCreated,
                OrganisationId = _id,
                Username       = _username,
                DisplayName    = "Joe Cool",
                Email          = "*****@*****.**",
                PhoneNumber    = "555 55555",
                Status         = OrganisationStatus.Live
            };

            _contactBeforeChange = new EpaContact
            {
                Id = _contactId,
                EndPointAssessorOrganisationId = _organisationIdCreated,
                Username    = _username,
                DisplayName = "Joe Cool",
                Email       = "*****@*****.**",
                PhoneNumber = "555 55555",
                Status      = OrganisationStatus.Live
            };

            _contactUpdated = new EpaContact
            {
                Id = _contactId,
                EndPointAssessorOrganisationId = _organisationIdCreated,
                Username    = _username,
                DisplayName = "Joe Cool changes",
                Email       = "*****@*****.**",
                PhoneNumber = "555 44444",
                Status      = OrganisationStatus.Live
            };
            OrganisationContactHandler.InsertRecord(_contactModel);
        }