示例#1
0
        public JsonResult UpdateOrganization(UIOrganization organization)
        {
            var repo = new Repository <Organization>();
            var org  = repo.Filter(q => q.Id == organization.Id).FirstOrDefault();

            org.MobileNo        = organization.MobileNo;
            org.Name            = organization.Name;
            org.Address         = organization.Address;
            org.CityId          = Convert.ToInt16(organization.City);
            org.ContactName     = organization.ContactName;
            org.Designation     = organization.Designation;
            org.Email           = organization.Email;
            org.Password        = !string.IsNullOrEmpty(organization.Password) ? StringCipher.Encrypt(organization.Password) :org.Password;
            org.RevenueId       = Convert.ToInt16(organization.Revenue);
            org.SectorId        = Convert.ToInt16(organization.Sector);
            org.StateId         = Convert.ToInt16(organization.State);
            org.SubSectorId     = Convert.ToInt16(organization.SubSector);
            org.TypeOfServiceId = Convert.ToInt16(organization.TypeOfService);
            org.IsActive        = organization.IsActive == "1" ? true: false;

            org.Cities         = repo.AssessmentContext.cities.FirstOrDefault(q => q.Id == org.CityId);
            org.States         = repo.AssessmentContext.states.FirstOrDefault(q => q.Id == org.StateId);
            org.Revenues       = repo.AssessmentContext.revenues.FirstOrDefault(q => q.Id == org.RevenueId);
            org.TypesOfService = repo.AssessmentContext.serviceTypes.FirstOrDefault(q => q.Id == org.Id);

            //org.Sectors = repo.AssessmentContext.sectors.FirstOrDefault(q => q.Id == org.SectorId);
            //org.SubSectors = repo.AssessmentContext.subSectors.FirstOrDefault(q => q.Id == org.SubSectorId);


            //this.registrationSendMail.Send(new MailConfiguration());

            repo.Update(org);
            repo.SaveChanges();
            return(Json(Utilities.Success, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public ValidationInformation RegistrationValidation(UIOrganization uIOrganization)
        {
            Repository <Organization> repository = new Repository <Organization>();

            if (uIOrganization.Name.Length < 6)
            {
                UserException.LogInformation("OrganizationName length should be 6 or More");
                this.validation.ErrorMessages.Add("OrganizationName length should be 6 or More");
            }
            else
            {
                var IsOrganization = repository.Find(t => t.IsActive && t.Name == uIOrganization.Name);
                if (IsOrganization != null && !string.IsNullOrEmpty(IsOrganization.Name))
                {
                    UserException.LogInformation("OrganizationName name is already present" + uIOrganization.Name);
                    this.validation.ErrorMessages.Add("OrganizationName is already present, Can you try some other name");
                }
                else
                {
                    IsOrganization = repository.Find(t => t.IsActive && t.Email == uIOrganization.Email);
                    if (IsOrganization != null && !string.IsNullOrEmpty(IsOrganization.Email))
                    {
                        UserException.LogInformation("OrganizationEmail is already present" + uIOrganization.Name);
                        this.validation.ErrorMessages.Add("OrganizationEmail is already present, Can you try some other E-Mail");
                    }
                }
            }

            if (this.validation.ErrorMessages.Count == 0)
            {
                this.validation.IsSuccess = true;
            }

            return(this.validation);
        }
示例#3
0
        public ActionResult CustomerDetails(int id, string level)
        {
            var uiOrganization = new UIOrganization();

            using (var org = new Repository <Organization>())
            {
                var selectOrg = org.Filter(q => q.Id == id).FirstOrDefault();

                uiOrganization = org.AssessmentContext.UserInfo.Where(q => q.Id == id).ToList().Join(org.AssessmentContext.cities, og => og.CityId, cy => cy.Id, (og, cy) => new { og, cy }).
                                 Join(org.AssessmentContext.states, s => s.og.StateId, st => st.Id, (s, st) => new { s, st, }).Join(org.AssessmentContext.serviceTypes,
                                                                                                                                    sty => sty.s.og.TypeOfServiceId, stype => stype.Id, (sty, stype) => new UIOrganization()
                {
                    Id            = id,
                    SelectLevel   = level,
                    Name          = sty.s.og.Name,
                    Address       = sty.s.og.Address,
                    City          = sty.s.cy.CityName,
                    Email         = sty.s.og.Email,
                    MobileNo      = sty.s.og.MobileNo,
                    State         = sty.st.StateName,
                    Designation   = sty.s.og.Designation,
                    TypeOfService = stype.Name,
                    Sector        = selectOrg.SectorId == 1000 ? Utilities.Others : org.AssessmentContext.sectors.Where(q => q.Id == selectOrg.SubSectorId).FirstOrDefault().SectorName,
                    SubSector     = selectOrg.SubSectorId == 1000 ? Utilities.Others :  org.AssessmentContext.subSectors.Where(q => q.Id == selectOrg.SubSectorId).FirstOrDefault().SubSectorName,
                    Revenue       = org.AssessmentContext.revenues.Where(q => q.Id == selectOrg.RevenueId).FirstOrDefault().Name,
                    Type          = selectOrg.TypeId == 1 ? Utilities.Small : selectOrg.TypeId == 2 ? Utilities.Large : Utilities.OperatingUnit
                }).FirstOrDefault();
            }
            return(View(uiOrganization));
        }
示例#4
0
        public JsonResult CreateOrganization(UIOrganization organization)
        {
            string errorMsg = string.Empty;
            ValidationInformation validation = new ValidationInformation();

            try
            {
                validation = this.businessContract.UserCreation(organization);
                if (validation.IsSuccess)
                {
                    errorMsg = Utilities.Success;
                }
                else
                {
                    errorMsg = Utilities.Failiure;
                }

                // TODO: Add insert logic here

                //return RedirectToAction("SuccesserrorMsg
            }
            catch (Exception ex)
            {
                UserException.LogException(ex);
                errorMsg = Utilities.Failiure;
                validation.ErrorMessages = new List <string>();
                validation.ErrorMessages.Add("Some Exception Occured, Please try again later");
                //return View();
            }

            if (errorMsg == Utilities.Success)
            {
                return(Json(errorMsg, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(JsonConvert.SerializeObject(validation), JsonRequestBehavior.AllowGet));
            }
        }
示例#5
0
 public Organization Registration(UIOrganization uiOrganization)
 {
     return(new Organization()
     {
         Address = uiOrganization.Address,
         ContactName = uiOrganization.ContactName,
         Designation = uiOrganization.Designation,
         Email = uiOrganization.Email,
         MobileNo = uiOrganization.MobileNo,
         Name = uiOrganization.Name,
         CityId = Convert.ToInt16(uiOrganization.City),
         RevenueId = Convert.ToInt16(uiOrganization.Revenue),
         SectorId = Convert.ToInt16(uiOrganization.Sector),
         SubSectorId = Convert.ToInt16(uiOrganization.SubSector),
         TypeId = Convert.ToInt16(uiOrganization.Type),
         TypeOfServiceId = Convert.ToInt16(uiOrganization.TypeOfService),
         UserId = uiOrganization.Name.Substring(0, 6),
         StateId = Convert.ToInt16(uiOrganization.State),
         CreateDate = DateTime.Now,
         CurrentAssignmentStatus = Utilities.AssessmentPendingStatus,
         CurrentAssignmentType = Utilities.AssessmentTypeLevel1
     });
 }
示例#6
0
        public JsonResult ViewOrganization(int id, string type)
        {
            var model = new UIOrganization();
            var repo  = new Repository <Organization>();
            var org   = repo.Filter(q => q.Id == id).FirstOrDefault();

            model.Id          = org.Id;
            model.Name        = org.Name;
            model.Address     = org.Address;
            model.ContactName = org.ContactName;
            model.Designation = org.Designation;
            model.Email       = org.Email;
            model.MobileNo    = org.MobileNo;


            if (type == "View")
            {
                model.City          = repo.AssessmentContext.cities.FirstOrDefault(c => c.Id == org.CityId).CityName;
                model.Revenue       = repo.AssessmentContext.revenues.FirstOrDefault(r => r.Id == org.RevenueId).Name;
                model.Sector        = (org.SectorId == 0 || org.SectorId == Convert.ToInt16(Utilities.OthersValue)) ? Utilities.Others : repo.AssessmentContext.sectors.FirstOrDefault(r => r.Id == org.SectorId).SectorName;
                model.SubSector     = (org.SectorId == 0 || org.SubSectorId == Convert.ToInt16(Utilities.OthersValue)) ? Utilities.Others : repo.AssessmentContext.subSectors.FirstOrDefault(r => r.Id == org.SubSectorId).SubSectorName;
                model.State         = org.StateId > 0 ? repo.AssessmentContext.states.FirstOrDefault(s => s.Id == org.StateId).StateName : "";
                model.TypeOfService = org.TypeOfServiceId > 0 ? repo.AssessmentContext.serviceTypes.FirstOrDefault(ty => ty.Id == org.TypeOfServiceId).Name : "";
            }
            else
            {
                model.City          = org.CityId.ToString();
                model.Revenue       = org.RevenueId.ToString();
                model.Sector        = org.SectorId.ToString();
                model.SubSector     = org.SubSectorId.ToString();
                model.State         = org.StateId.ToString();
                model.TypeOfService = org.TypeOfServiceId.ToString();
            }

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        // GET: ManageUser
        public ActionResult Index()
        {
            var uiOrganization = new UIOrganization();

            using (var org = new Repository <Organization>())
            {
                var selectOrg = org.Filter(q => q.Id == this.UserId).FirstOrDefault();

                uiOrganization = org.AssessmentContext.UserInfo.Where(q => q.Id == this.UserId).ToList().Join(org.AssessmentContext.cities, og => og.CityId, cy => cy.Id, (og, cy) => new { og, cy }).
                                 Join(org.AssessmentContext.states, s => s.og.StateId, st => st.Id, (s, st) => new { s, st, }).Join(org.AssessmentContext.serviceTypes,
                                                                                                                                    sty => sty.s.og.TypeOfServiceId, stype => stype.Id, (sty, stype) => new UIOrganization()
                {
                    Name          = sty.s.og.Name,
                    Address       = sty.s.og.Address,
                    City          = sty.s.cy.CityName,
                    Email         = sty.s.og.Email,
                    MobileNo      = sty.s.og.MobileNo,
                    State         = sty.st.StateName,
                    Designation   = sty.s.og.Designation,
                    TypeOfService = stype.Name
                }).FirstOrDefault();
            }
            return(View(uiOrganization));
        }
示例#8
0
        public static List <UIOrganization> AssignOrganizationByFilter(Organization org, bool orgEnable = false)
        {
            var lmodel           = new List <UIOrganization>();
            var listOrganization = new List <Organization>();
            var orgHistory       = new List <OrganizationLevelHistory>();

            using (var repo = new Repository <Organization>())
            {
                listOrganization = repo.All().ToList();
                orgHistory       = repo.AssessmentContext.organizationLevelHistories.ToList();
            }

            orgHistory.ForEach(t =>
            {
                if (orgEnable)
                {
                    listOrganization.Add(new Organization()
                    {
                        AssessmentId          = t.AssessmentId,
                        CurrentAssignmentType = t.Level,
                        CityId          = t.CityId,
                        StateId         = t.StateId,
                        SectorId        = t.SectorId,
                        SubSectorId     = t.SubSectorId,
                        RevenueId       = t.RevenueId,
                        TypeOfServiceId = t.TypeOfServiceId,
                        Id = t.OrgId,
                        CurrentAssignmentStatus = t.Status
                    });
                }
            });

            //if (org.AssessmentId > 0)
            //    listOrganization = listOrganization.Where(q => q.AssessmentId == org.AssessmentId).ToList();

            if (!string.IsNullOrEmpty(org.CurrentAssignmentType))
            {
                listOrganization = listOrganization.Where(q => q.CurrentAssignmentType == org.CurrentAssignmentType).ToList();
            }

            if (org.CityId > 0)
            {
                listOrganization = listOrganization.Where(q => q.CityId == org.CityId).ToList();
            }
            if (org.StateId > 0)
            {
                listOrganization = listOrganization.Where(q => q.StateId == org.StateId).ToList();
            }
            if (org.SectorId > 0 && org.SectorId != 1000 && org.SectorId != 1001) // Skip for others and All
            {
                listOrganization = listOrganization.Where(q => q.SectorId == org.SectorId).ToList();
            }
            if (org.RevenueId > 0)
            {
                listOrganization = listOrganization.Where(q => q.RevenueId == org.RevenueId).ToList();
            }
            if (org.SubSectorId > 0 && org.SubSectorId != 1000 && org.SubSectorId != 1001)
            {
                listOrganization = listOrganization.Where(q => q.SubSectorId == org.SubSectorId).ToList();
            }
            if (org.TypeOfServiceId > 0)
            {
                listOrganization = listOrganization.Where(q => q.TypeOfServiceId == org.TypeOfServiceId).ToList();
            }

            var city = new Repository <City>();

            try
            {
                listOrganization.ForEach(q =>
                {
                    UIOrganization model = new UIOrganization();
                    model.IsActive       = org.IsActive == true ? "checked" : "Unchecked";
                    model.Id             = q.Id;
                    model.Name           = !string.IsNullOrEmpty(q.Name) ? q.Name : city.AssessmentContext.UserInfo.FirstOrDefault(t => t.Id == q.Id).Name;
                    model.City           = city.Filter(c => c.Id == q.CityId).FirstOrDefault().CityName;
                    model.Revenue        = city.AssessmentContext.revenues.FirstOrDefault(r => r.Id == q.RevenueId).Name;
                    model.Sector         = (q.SectorId == 0 || q.SectorId == 1000 || q.SectorId == 1001) ? Utilities.Others : city.AssessmentContext.sectors.FirstOrDefault(r => r.Id == q.SectorId).SectorName;
                    model.SubSector      = (q.SectorId == 0 || q.SubSectorId == 1000 || q.SubSectorId == 1001) ? Utilities.Others : city.AssessmentContext.subSectors.FirstOrDefault(r => r.Id == q.SubSectorId).SubSectorName;
                    model.State          = q.StateId > 0 ? city.AssessmentContext.states.FirstOrDefault(s => s.Id == q.StateId).StateName : "";
                    model.TypeOfService  = q.TypeOfServiceId > 0 ? city.AssessmentContext.serviceTypes.FirstOrDefault(ty => ty.Id == q.TypeOfServiceId).Name : "";
                    model.Type           = org.CurrentAssignmentType;
                    model.Status         = q.CurrentAssignmentStatus;
                    lmodel.Add(model);
                });
            }
            catch (Exception ex)
            {
                //throw;
            }

            return(lmodel);
        }
        public ValidationInformation UserCreation(UIOrganization uIOrganization)
        {
            ValidationInformation validation = this.userBValidation.RegistrationValidation(uIOrganization);

            if (validation.IsSuccess)
            {
                string   password  = GenerateTempPassword(8, 2);
                string[] sector    = new string[2];
                string[] subSector = new string[2];
                Others   other     = new Others();

                bool isOthers = false;
                if (uIOrganization.Sector.Contains(Utilities.OthersValue))
                {
                    sector = uIOrganization.Sector.Split(Utilities.SplitValue);
                    uIOrganization.Sector = sector[0];
                    other.Sector          = sector[1];
                    isOthers = true;
                }
                else
                {
                    other.Sector = string.Empty;
                }

                if (uIOrganization.SubSector.Contains(Utilities.OthersValue))
                {
                    subSector = uIOrganization.SubSector.Split(Utilities.SplitValue);
                    uIOrganization.SubSector = subSector[0];
                    other.SubSector          = subSector[1];
                    isOthers = true;
                }
                else
                {
                    other.SubSector = string.Empty;
                }


                using (Repository <Organization> repository = new Repository <Organization>())
                {
                    Organization organization = this.organizationMapper.Registration(uIOrganization);
                    organization.Cities         = repository.AssessmentContext.cities.FirstOrDefault(q => q.Id == organization.CityId);
                    organization.States         = repository.AssessmentContext.states.FirstOrDefault(q => q.Id == organization.StateId);
                    organization.Revenues       = repository.AssessmentContext.revenues.FirstOrDefault(q => q.Id == organization.RevenueId);
                    organization.TypesOfService = repository.AssessmentContext.serviceTypes.FirstOrDefault(q => q.Id == organization.Id);

                    //organization.Sectors = repository.AssessmentContext.sectors.FirstOrDefault(q => q.Id == organization.SectorId);
                    //organization.SubSectors = repository.AssessmentContext.subSectors.FirstOrDefault(q => q.Id == organization.SubSectorId);
                    organization.SectorId    = isOthers ? Convert.ToInt16(Utilities.SectorValue) : repository.AssessmentContext.sectors.FirstOrDefault(q => q.Id == organization.SectorId).Id;
                    organization.SubSectorId = isOthers ? Convert.ToInt16(Utilities.SectorValue) : repository.AssessmentContext.subSectors.FirstOrDefault(q => q.Id == organization.SubSectorId).Id;

                    int assessmentid  = 0;
                    var listAssesment = new List <Assessment>();
                    int sectorValue   = Convert.ToInt16(Utilities.SectorValue);

                    listAssesment = repository.AssessmentContext.assessments.Where(q => q.Sector == organization.SectorId).ToList();

                    if (listAssesment == null || listAssesment.Count == 0)
                    {
                        listAssesment = repository.AssessmentContext.assessments.Where(q => q.Sector == sectorValue).ToList();
                    }

                    if (listAssesment != null && listAssesment.Count > 0)
                    {
                        var subAssessment = listAssesment.FirstOrDefault(q => q.SubSector == organization.SubSectorId);
                        if (subAssessment != null && subAssessment.Id > 0)
                        {
                            assessmentid = subAssessment.Id;
                        }
                        else
                        {
                            assessmentid = listAssesment[0].Id;
                        }
                    }
                    organization.AssessmentId = assessmentid;

                    organization.TempPassword = password;
                    repository.Create(organization);
                    repository.SaveChanges();
                }

                if (isOthers)
                {
                    other.OrganizationId = uIOrganization.Name.Substring(0, 6);
                    using (Repository <Others> repository = new Repository <Others>())
                    {
                        //other.Organizations = repository.AssessmentContext.UserInfo.FirstOrDefault(q => q.Name == other.OrganizationId);
                        repository.Create(other);
                        repository.SaveChanges();
                    }
                }

                validation.IsSuccess = true;

                Repository <Template> template = new Repository <Template>();
                var registrationTemplate       = template.Filter(q => q.Name.StartsWith(Utilities.RegistrationTemplateName)).FirstOrDefault();
                if (registrationTemplate != null && !string.IsNullOrWhiteSpace(registrationTemplate.Description))
                {
                    RegistrationSendMail.SendMail(registrationTemplate.Description, Utilities.RegistrationSubject, uIOrganization.Email, uIOrganization.Name);
                }
                //this.registrationSendMail.Send(new MailConfiguration());
            }
            else
            {
                validation.IsSuccess = false;
            }
            return(validation);
        }