public static List<int> CheckLusherAnswers(long surveyResultId, List<SurveysAnswerContent> surveysAnswerContents)
        {
            using (var lusherRepository = new BaseRepository<LusherAnswer>())
            {
                SurveysResult surveysResult =
                    lusherRepository.Context.SurveysResults.FirstOrDefault(x => x.Id == surveyResultId);
                if (surveysResult == null)
                {
                    throw new SurveysResultDoesNotExistException();
                }

                // Check surveyResultMethod.MethodsId = id of test lusher pair
                Test test = lusherRepository.Context.Tests.FirstOrDefault(x => x.Id == surveysResult.MethodsId);
                if (test == null)
                {
                    return null;
                }
                if (!String.Equals(test.CodeName, Constraints.KLusherPairCodeName))
                {
                    return null;
                }

                String answerStr = ResultConverter.GenerateAnswerString(test.CodeName, surveysAnswerContents);

                // Check lusher Answers for special question
                // Invoke static method from LusherPairMethod from Consul Shell
                return LusherPairMethod.CheckAnswers(answerStr);
            }
        }
        public ActionResult Edit(FirmExt model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    string Msg = "";
                    FirmRepository uRepo = new FirmRepository();
                    if (uRepo.Update(model, ref Msg, this))
                    {
                        return RedirectToAction("Index", "Firm");
                    }
                }
                catch (Exception ex)
                {
                    string hostName1 = Dns.GetHostName();
                    string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString();
                    string PageName = Convert.ToString(Session["PageName"]);
                    //string GetUserIPAddress = GetUserIPAddress1();
                    using (BaseRepository baseRepo = new BaseRepository())
                    {
                        //BizContext BizContext1 = new BizContext();
                        BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress);
                    }
                    Session["PageName"] = "";
                    ModelState.AddModelError("", "Error: Please Correct/Enter All the Information below to Save this Record, All Fields are Mandatory");
                    ErrorHandling.HandleModelStateException(ex, ModelState);
                }
            }

            return View(model);
        }
        public ActionResult _Create([DataSourceRequest]DataSourceRequest request, TB_TypeFirmRequestStatusExt model)
        {
            if (ModelState.IsValid)
            {
                string Msg = "";
                try
                {
                    TB_TypeFirmRequestStatusRepository modelRepo = new TB_TypeFirmRequestStatusRepository();
                    if (modelRepo.Create(model, ref Msg, this) == false)
                    {
                        return this.Json(new DataSourceResult { Errors = Msg });
                    }
                }
                catch (Exception ex)
                {
                    string hostName1 = Dns.GetHostName();
                    string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString();
                    string PageName = Convert.ToString(Session["PageName"]);
                    //string GetUserIPAddress = GetUserIPAddress1();
                    using (BaseRepository baseRepo = new BaseRepository())
                    {
                        //BizContext BizContext1 = new BizContext();
                        BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress);
                    }
                    Session["PageName"] = "";
                    string error = ErrorHandling.HandleException(ex);
                    return this.Json(new DataSourceResult { Errors = error });
                }
            }

            return Json(new[] { model }.ToDataSourceResult(request, ModelState));
        }
 public Package GetPackages(int packageId)
 {
     using (var packageRepository = new BaseRepository<Package>())
     {
         return packageRepository.GetAllItems.FirstOrDefault(x => x.Id == packageId);
     }
 }
        public override ValidationResult Validate(object value,
        System.Globalization.CultureInfo cultureInfo)
        {
            BindingGroup bg = value as BindingGroup;
            if (bg == null) { return ValidationResult.ValidResult; }
            if (bg.Items.Count > 0)
            {
                Peoples tempValue = (value as BindingGroup).Items[0] as Peoples;
                try
                {
                    BaseRepository<Peoples> peoples = new BaseRepository<Peoples>();
                    var temp = (from peopl in peoples.items where tempValue.inn == peopl.inn select peopl).Count<Peoples>();
                    if (temp == 1)
                    {
                        peoples.SaveChages();
                        return ValidationResult.ValidResult;
                        
                    }

                    return new ValidationResult(false, "Найдено совпадение ИНН");
                }
                catch (Exception ex)
                {
                    return new ValidationResult(false, ex.Message);
                }
            }
            return ValidationResult.ValidResult;
        }
Exemple #6
0
 public IEnumerable<Test> GetTests()
 {
     using (var repo = new BaseRepository<Test>())
     {
         return repo.GetAllItems.ToList();
     }
 }
 public JsonResult DeleteHotelRoom(int HotelRoomID)
 {
     int i = 1;
     PropertyRoomsRepository obj = new PropertyRoomsRepository();
     try
     {
         i = obj.DeleteHotelRoom(HotelRoomID, this);
     }
     catch (Exception ex)
     {
         string hostName1 = Dns.GetHostName();
         string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString();
         string PageName = Convert.ToString(Session["PageName"]);
         //string GetUserIPAddress = GetUserIPAddress1();
         using (BaseRepository baseRepo = new BaseRepository())
         {
             //BizContext BizContext1 = new BizContext();
             BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress);
         }
         Session["PageName"] = "";
         string error = ErrorHandling.HandleException(ex);
         return this.Json(new DataSourceResult { Errors = error });
     }
     return Json(i, JsonRequestBehavior.AllowGet);
 }
 public static List<SurveysShellResult> GetAllShellResults()
 {
     using (var resultRepository = new BaseRepository<SurveysShellResult>())
     {
         return resultRepository.GetAllItems.ToList();
     }
 }
        public OldUser AuthorizeUser(string login, string password)
        {
            using (var _userRepository = new BaseRepository<OldUser>())
            {
                //var OldUser = _userRepository.GetAllItems.FirstOrDefault(x => x.Login == login && x.Password == password);
                var user = _userRepository.Context.OldUsers.Include("Role").FirstOrDefault(x => x.Login == login && x.Password == password);
                if (user == null)
                {
                    throw new UserDoesNotExistException();
                }

                if (user.ExpirationDate < DateTime.Now)
                {
                    // session is not valid, update token
                    user.Token = Guid.NewGuid();
                }

                user.ExpirationDate = DateTime.Now.AddMinutes(20);

                if (_userRepository.Update(user).Status)
                {
                    return user;
                }
            }
            throw new UpdateException();
        }
Exemple #10
0
 /// <summary>
 /// Get role by Id
 /// DB table Roles
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Role GetRoleById(int id)
 {
     using (var roleRepository = new BaseRepository<Role>())
     {
         return roleRepository.GetAllItems.FirstOrDefault(x => x.Id == id);
     }
 }
Exemple #11
0
 /// <summary>
 /// Return list of Roles
 /// DB table Roles
 /// </summary>
 /// <returns></returns>
 public List<Role> GetRoles()
 {
     using (var roleRepository = new BaseRepository<Role>())
     {
         return roleRepository.GetAllItems.ToList();
     }
 }
Exemple #12
0
 public List<ShutzQuestion> GetAllQuestions()
 {
     using (var shutzQuestionRepository = new BaseRepository<ShutzQuestion>())
     {
         return shutzQuestionRepository.Context.ShutzQuestions.Include("ShutzAnswers").ToList();
     }
 }
Exemple #13
0
 public List<KotQuestion> GetAllQuestions()
 {
     using (var kotQuestionRepository = new BaseRepository<KotQuestion>())
     {
         return kotQuestionRepository.Context.KotQuestions.Include("KotAnswers").ToList();
     }
 }
        public static List<LusherPairScenarioItem> GetSpecialQuestion(List<int> colorNumbers)
        {
            using (var lusherPairRepository = new BaseRepository<LusherPairQuestion>())
            {
                List<LusherAnswer> specialColors = new List<LusherAnswer>();
                foreach (var colorNumber in colorNumbers)
                {
                    specialColors.Add(lusherPairRepository.Context.LusherAnswers.FirstOrDefault(x => x.Number == colorNumber));
                }
                LusherPairQuestion specialQuestion = lusherPairRepository.GetAllItems.FirstOrDefault(x => x.Id != 1);
                if (specialQuestion == null)
                {
                    throw new QuestionDoesNotExistException();
                }

                List<LusherPairScenarioItem> scenarioItems = new List<LusherPairScenarioItem>();

                LusherPairScenarioItem scenarioItem = new LusherPairScenarioItem();
                scenarioItem.Steps = new List<LusherPairQuestion>() { specialQuestion };
                scenarioItem.Answers = specialColors;
                scenarioItem.UniqueAnswer = true;
                scenarioItems.Add(scenarioItem);

                return scenarioItems;
            }
        }
Exemple #15
0
 public static Test GetTest(int id)
 {
     using (var testRepository = new BaseRepository<Test>())
     {
         return testRepository.GetAllItems.FirstOrDefault(x => x.Id == id);
     }
 }
 public OldUser GetUserByCredentials(string login, string password)
 {
     using (var _repository = new BaseRepository<OldUser>())
     {
         return _repository.Context.OldUsers.Include("Role").FirstOrDefault(x => x.Login == login && x.Password == password);
     }
 }
Exemple #17
0
 public Test GetTestById(int id)
 {
     using (var repo = new BaseRepository<Test>())
     {
         return repo.GetAllItems.ToList().FirstOrDefault(x => x.Id == id);
     }
 }
 public Price GetServicePrice(int id)
 {
     using (var priceRepository = new BaseRepository<Price>())
     {
         return priceRepository.GetAllItems.FirstOrDefault(x => x.ServiceId == id);
     }
 }
        public override ValidationResult Validate(object value,
        System.Globalization.CultureInfo cultureInfo)
        {
            BindingGroup bg = value as BindingGroup;
            if (bg == null) { return ValidationResult.ValidResult; }
            if (bg.Items.Count > 0)
            {
                UBD_sertificate tempValue = (value as BindingGroup).Items[0] as UBD_sertificate;
                try
                {
                    BaseRepository<UBD_sertificate> sertificats = new BaseRepository<UBD_sertificate>();

                    var temp = (from sertif in sertificats.items
                                where sertif.id_people==tempValue.id_people && sertif.certificate_number==tempValue.certificate_number
                                select sertif).Count<UBD_sertificate>();
                    if (temp == 1)
                    {
                        sertificats.SaveChages();
                        return ValidationResult.ValidResult;

                    }

                    return new ValidationResult(false, "Запись о даном удостоверении уже существует!!!");
                }
                catch (Exception ex)
                {
                    return new ValidationResult(false, ex.Message);
                }
            }
            return ValidationResult.ValidResult;
        }
 public List<Service> GetServices()
 {
     using (var serviceRepository = new BaseRepository<Service>())
     {
         return serviceRepository.Context.Services.Include("ConclusionType").ToList();
     }
 }
 public List<Package> GetPackages()
 {
     using (var packageRepository = new BaseRepository<Package>())
     {
         return packageRepository.GetAllItems.ToList();
     }
 }
 public List<Service> GetServices(String methodsType, int methodsId)
 {
     using (var serviceRepository = new BaseRepository<Service>())
     {
         if (String.Equals(methodsType, Constraints.KMethodsTypeTest, StringComparison.CurrentCultureIgnoreCase))
         {
             Test test = serviceRepository.Context.Tests.FirstOrDefault(x => x.Id == methodsId);
             if (test == null)
             {
                 throw new MethodsDoesNotExistException();
             }
         }
         else if (String.Equals(methodsType, Constraints.KMethodsTypePackage, StringComparison.CurrentCultureIgnoreCase))
         {
             Package package = serviceRepository.Context.Packages.FirstOrDefault(x => x.Id == methodsId);
             if (package == null)
             {
                 throw new MethodsDoesNotExistException();
             }
         }
         else
         {
             throw new MethodsDoesNotExistException();
         }
         return serviceRepository.Context.Services.Include("ConclusionType").Where(x => x.MethodsId == methodsId && String.Equals(x.MethodsType.ToLower(), methodsType)).ToList();
     }
 }
        public JsonResult DisplayFirmInformation()
        {
            var Value = "";

            try
            {
                BizContext = (BizContext)Session["GBAdminBizContext"];
                int id = Convert.ToInt32(BizContext.FirmID);
                Session["GBAdminBizContext"] = BizContext;
                FirmInformationRepository objupdate = new FirmInformationRepository();
                var i = objupdate.GetFirmInfo(id);
                Value = Convert.ToString(i);
            }
            catch(Exception ex)
            {
                string hostName1 = Dns.GetHostName();
                string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString();
                string PageName = Convert.ToString(Session["PageName"]);
                //string GetUserIPAddress = GetUserIPAddress1();
                using (BaseRepository baseRepo = new BaseRepository())
                {
                    //BizContext BizContext1 = new BizContext();
                    BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress);
                }
                Session["PageName"] = "";
                string error = ErrorHandling.HandleException(ex);
                return this.Json(new DataSourceResult { Errors = error });
            }

            return Json(Value, JsonRequestBehavior.AllowGet);
        }
 public Service GetServices(int id)
 {
     using (var serviceRepository = new BaseRepository<Service>())
     {
         return serviceRepository.Context.Services.Include("ConclusionType").ToList().FirstOrDefault(x => x.Id == id);
     }
 }
        public ActionResult ContactUs()
        {
            Session["PageName"] = "ContactUs";
               // string id = "";
            try
            {
                ContactUsRepository objupdate = new ContactUsRepository();
                List<ContactUsExt> Value = objupdate.GetContactUs();
                ViewBag.Value = Value;
                AssignBizContext();
                SecurityUtils.SetGlobalViewbags(this, ActiveMenu, BizContext.UserContext.IsAdmin(), BizContext.UserContext.IsHotelAdmin(), BizContext.HotelID);
            }
            catch(Exception ex)
            {
                string hostName1 = Dns.GetHostName();
                string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString();
                string PageName = Convert.ToString(Session["PageName"]);
                //string GetUserIPAddress = GetUserIPAddress1();
                using (BaseRepository baseRepo = new BaseRepository())
                {
                    //BizContext BizContext1 = new BizContext();
                    BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress);
                }
                Session["PageName"] = "";
                string error = ErrorHandling.HandleException(ex);
                return this.Json(new DataSourceResult { Errors = error });
            }

            return View();
        }
        public JsonResult deletefirmrequest(int ID)
        {
            string Msg = "";
            string request = "false";
            try
            {
                FirmRequestsRepository modelRepo = new FirmRequestsRepository();
                FirmRequestExt model = new FirmRequestExt();

                if (modelRepo.deletefirmrequest(ID, this) == false)
                {
                    return this.Json(new DataSourceResult { Errors = Msg });
                }
                request = "true";
            }
            catch (Exception ex)
            {
                string hostName1 = Dns.GetHostName();
                string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString();
                string PageName = Convert.ToString(Session["PageName"]);
                //string GetUserIPAddress = GetUserIPAddress1();
                using (BaseRepository baseRepo = new BaseRepository())
                {
                    //BizContext BizContext1 = new BizContext();
                    BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress);
                }
                Session["PageName"] = "";
                string error = ErrorHandling.HandleException(ex);
                return this.Json(new DataSourceResult { Errors = error });

            }

            return Json(request);
        }
        public override ValidationResult Validate(object value,
        System.Globalization.CultureInfo cultureInfo)
        {
            BindingGroup bg = value as BindingGroup;
            if (bg == null) { return ValidationResult.ValidResult; }
            if (bg.Items.Count > 0)
            {
                period_in_ATO tempValue = (value as BindingGroup).Items[0] as period_in_ATO;
                try
                {
                    BaseRepository<period_in_ATO> periods = new BaseRepository<period_in_ATO>();

                    var temp = (from period in periods.items
                                where Comparator(period, tempValue)
                                select period).Count<period_in_ATO>();
                    if (temp == 1)
                    {
                        periods.SaveChages();
                        return ValidationResult.ValidResult;

                    }

                    return new ValidationResult(false, "Найдено совпадение периодов!!! Проверьте даты...");
                }
                catch (Exception ex)
                {
                    return new ValidationResult(false, ex.Message);
                }
            }
            return ValidationResult.ValidResult;
        }
Exemple #28
0
        public static bool CheckTestPackage(String methodsType, int methodsId)
        {
            using(var testRepository = new BaseRepository<Test>())
            {
                //return (
                //           (String.Equals(methodsType, Constraints.KMethodsTypeTest) &&
                //            testRepository.Context.Tests.Any(x => x.Id == methodsId)) |

                //           (String.Equals(methodsType, Constraints.KMethodsTypePackage) &&
                //            testRepository.Context.Packages.Any(x => x.Id == methodsId))
                //       );

                if ((String.Equals(methodsType, Constraints.KMethodsTypeTest) &&
                            testRepository.Context.Tests.Any(x => x.Id == methodsId)))
                {
                    return true;
                }
                if ((String.Equals(methodsType, Constraints.KMethodsTypePackage) &&
                            testRepository.Context.Packages.Any(x => x.Id == methodsId)))
                {
                    return true;
                }
                return false;
            }
        }
        public ActionResult _Read([DataSourceRequest]DataSourceRequest request, int TableID)
        {
            DataSourceResult result = null;
            try
            {
                TB_TourRegionHistoryRepository modelRepo = new TB_TourRegionHistoryRepository();
                 result = modelRepo.ReadAll(TableID).ToDataSourceResult(request);
            }
            catch (Exception ex)
            {
                string hostName1 = Dns.GetHostName();
                string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString();
                string PageName = Convert.ToString(Session["PageName"]);
                //string GetUserIPAddress = GetUserIPAddress1();
                using (BaseRepository baseRepo = new BaseRepository())
                {
                    //BizContext BizContext1 = new BizContext();
                    BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress);
                }
                Session["PageName"] = "";
                string error = ErrorHandling.HandleException(ex);
                return this.Json(new DataSourceResult { Errors = error });
            }

            return Json(result);
        }
        public CuratorMethodicsGroup CreateCuratorMethodicsGroup(long curatorId, CuratorMethodicsGroup methodicsGroup)
        {
            using (var methodicsGroupsRepository = new BaseRepository<CuratorMethodicsGroup>())
            {
                Client curator = methodicsGroupsRepository.Context.Clients.FirstOrDefault(x => x.Id == curatorId);
                if (curator == null)
                {
                    throw new UserDoesNotExistException();
                }

                if (String.IsNullOrWhiteSpace(methodicsGroup.Name))
                {
                    throw new RequireFieldException();
                }

                if (methodicsGroupsRepository.GetAllItems.Any(x => String.Equals(x.Name, methodicsGroup.Name) && x.Curator.Id == curatorId))
                {
                    throw new MethodicsGroupNameException();
                }

                methodicsGroup.Curator = curator;

                if (!methodicsGroupsRepository.Create(methodicsGroup).Status)
                {
                    throw new CreateException();
                }

                return methodicsGroup;
            }
        }