public void Can_Instantiate_Repository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();

            // Act
            var languageRepository = new LanguageRepository(unitOfWork);
            var repository = new DictionaryRepository(unitOfWork, languageRepository);

            // Assert
            Assert.That(repository, Is.Not.Null);
        }
        public ActionResult Edit(int id)
        {
            try
            {
                DictionaryRepository ml = new DictionaryRepository();

                Dictionary obj = ml.GetDictionary(id);

                return(View(obj));
            }
            catch (Exception ex)
            {
                return(Content(ContentIcon.Error + "|" + ErrorWirter(RouteData, ex.Message)));
            }
        }
Exemple #3
0
        public JsonResult CreateSender(string firstName, string lastName, string company, string position,
                                       string email, string webpage, string phonehome, string phonemobile, string phonework,
                                       string faxwork, string postCode, string city, string street, string building, string flat, string post, string notes)
        {
            DictionaryRepository _repository = new DictionaryRepository();

            Sender sender = new Sender()
            {
                FirstName   = firstName,
                LastName    = lastName,
                Company     = company,
                Position    = position,
                Email       = email,
                Webpage     = webpage,
                PhoneHome   = phonehome,
                PhoneMobile = phonemobile,
                PhoneWork   = phonework,
                FaxWork     = faxwork,
                PostCode    = postCode,
                Post        = post,
                City        = city,
                Street      = street,
                Building    = building,
                Flat        = flat,
                Notes       = notes,
                ClientID    = AppContext.GetCID()
            };

            _repository.CreateSender(sender);
            _repository.SubmitChanges();

            List <Sender> senders = _repository.GetSenders().ToList();

            List <SelectListItem> list = new List <SelectListItem>();

            foreach (Sender s in senders)
            {
                bool selected = (s.FirstName.Equals(firstName) && s.LastName.Equals(lastName) && s.Company.Equals(company));
                list.Add(new SelectListItem()
                {
                    Text     = s.FullName,
                    Value    = s.SenderID.ToString(),
                    Selected = selected
                });
            }

            return(Json(list));
        }
Exemple #4
0
        public ActionResult MaterialListPartialVew(Guid?ddId)
        {
            DictionaryRepository repository = new DictionaryRepository();
            Guid?mpSample = repository.GetDictionaryElementIdByTypeAndCode(Dictionary.MaterialRdType.DicCode, Dictionary.MaterialRdType.MpSample);
            CreateMaterialViewModel model = new CreateMaterialViewModel()
            {
                DrugDeclarationId = ddId
            };

            if (mpSample.HasValue)
            {
                model.TypeIdDefaultValue = mpSample.Value;
            }

            return(PartialView(model));
        }
Exemple #5
0
        public void Can_Perform_Count_On_DictionaryRepository()
        {
            // Arrange
            var provider           = new PetaPocoUnitOfWorkProvider();
            var unitOfWork         = provider.GetUnitOfWork();
            var languageRepository = new LanguageRepository(unitOfWork);
            var repository         = new DictionaryRepository(unitOfWork, languageRepository);

            // Act
            var query = Query <IDictionaryItem> .Builder.Where(x => x.ItemKey.StartsWith("Read"));

            var result = repository.Count(query);

            // Assert
            Assert.That(result, Is.EqualTo(1));
        }
        public void Can_Perform_GetAll_With_Params_On_DictionaryRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var languageRepository = new LanguageRepository(unitOfWork);
            var repository = new DictionaryRepository(unitOfWork, languageRepository);

            // Act
            var dictionaryItems = repository.GetAll(1, 2);

            // Assert
            Assert.That(dictionaryItems, Is.Not.Null);
            Assert.That(dictionaryItems.Any(), Is.True);
            Assert.That(dictionaryItems.Any(x => x == null), Is.False);
            Assert.That(dictionaryItems.Count(), Is.EqualTo(2));
        }
Exemple #7
0
        public Campaign GetCurrent()
        {
            if (!Tracker.Current.Interaction.CampaignId.HasValue)
            {
                return(null);
            }
            var campaignId = Tracker.Current.Interaction.CampaignId.Value.ToID();
            var campaign   = GetCampaignDefinition(campaignId);

            return(new Campaign()
            {
                Title = campaign?.Name ?? DictionaryRepository.Get("/Demo/Campaigns/UnknownCampaign", "(Unknown)"),
                IsActive = true,
                Date = Tracker.Current.Interaction.StartDateTime,
                Channel = GetChannel(campaign)
            });
        }
Exemple #8
0
        public void Can_Perform_GetAll_With_Params_On_DictionaryRepository()
        {
            // Arrange
            var provider           = new PetaPocoUnitOfWorkProvider();
            var unitOfWork         = provider.GetUnitOfWork();
            var languageRepository = new LanguageRepository(unitOfWork);
            var repository         = new DictionaryRepository(unitOfWork, languageRepository);

            // Act
            var dictionaryItems = repository.GetAll(1, 2);

            // Assert
            Assert.That(dictionaryItems, Is.Not.Null);
            Assert.That(dictionaryItems.Any(), Is.True);
            Assert.That(dictionaryItems.Any(x => x == null), Is.False);
            Assert.That(dictionaryItems.Count(), Is.EqualTo(2));
        }
Exemple #9
0
        public IEnumerable <Campaign> GetHistoric()
        {
            var keyBehaviourCache = Tracker.Current.Contact.GetKeyBehaviorCache();

            foreach (var cachedCampaign in keyBehaviourCache.Campaigns)
            {
                var campaign = GetCampaignDefinition(cachedCampaign.Id.ToID());

                yield return(new Campaign()
                {
                    Title = campaign?.Name ?? DictionaryRepository.Get("/Demo/Campaigns/UnknownCampaign", "(Unknown)"),
                    IsActive = false,
                    Date = cachedCampaign.DateTime,
                    Channel = GetChannel(campaign)
                });
            }
        }
Exemple #10
0
        private IEnumerable <Goal> GetHistoric()
        {
            var keyBehaviourCache = Tracker.Current.Contact.GetKeyBehaviorCache();

            foreach (var cachedGoal in keyBehaviourCache.Goals)
            {
                var goal = GetGoalDefinition(cachedGoal.Id.ToID());

                yield return(new Goal
                {
                    Title = goal?.Name ?? DictionaryRepository.Get("/Demo/Goals/UnknownGoal", "(Unknown)"),
                    Date = cachedGoal.DateTime,
                    EngagementValue = goal?.EngagementValuePoints ?? 0,
                    IsCurrentVisit = false
                });
            }
        }
Exemple #11
0
        // GET: OrderTmc
        public PartialViewResult OrderTmcView(Guid tmcId, Guid?id = null, string note = "", bool isEdit = false)
        {
            TmcRepository  tmcRepository = new TmcRepository(false);
            LimsTmcOutView toc           = new LimsTmcOutView()
            {
                Id       = tmcId,
                TmcId    = tmcId,
                TmcOutId = id ?? Guid.Empty
            };

            if (id == null)
            {
                var tmcOrdering = tmcRepository.GetAsQuarable(tmc => tmc.Id == tmcId).FirstOrDefault();
                if (tmcOrdering != null)
                {
                    toc.Name                    = tmcOrdering.Name;
                    toc.Count                   = tmcOrdering.CountActual;
                    toc.OwnerEmployeeId         = tmcOrdering.OwnerEmployeeId;
                    toc.MeasureTypeConvertDicId = tmcOrdering.MeasureTypeConvertDicId;
                }

                DictionaryRepository dicRep = new DictionaryRepository(false);
                var outTypeId = dicRep.GetAsQuarable(d => d.Type == Dictionary.OutTypes.DicCode && d.ExpireDate == null)
                                .Select(d => d.Id)
                                .FirstOrDefault();
                toc.OutTypeDicId = outTypeId;
                toc.Note         = note;
            }
            else
            {
                OrderTmcRepository otRepo = new OrderTmcRepository(false);
                toc = otRepo.LimsTmcOutViewGetAsQuarable(lto => lto.TmcId == tmcId && lto.TmcOutId == id).FirstOrDefault();

                var tmcOrdering = tmcRepository.GetAsQuarable(tmc => tmc.Id == tmcId).FirstOrDefault();
                if (tmcOrdering != null && toc != null)
                {
                    toc.MeasureTypeConvertDicId = tmcOrdering.MeasureTypeConvertDicId;
                }
            }
            if (toc != null)
            {
                toc.IsEdit = isEdit;
            }
            return(PartialView(toc));
        }
Exemple #12
0
        public void Can_Perform_GetByQuery_On_DictionaryRepository()
        {
            // Arrange
            var provider           = new PetaPocoUnitOfWorkProvider();
            var unitOfWork         = provider.GetUnitOfWork();
            var languageRepository = new LanguageRepository(unitOfWork);
            var repository         = new DictionaryRepository(unitOfWork, languageRepository);

            // Act
            var query = Query <IDictionaryItem> .Builder.Where(x => x.ItemKey == "Article");

            var result = repository.GetByQuery(query);

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Any(), Is.True);
            Assert.That(result.FirstOrDefault().ItemKey, Is.EqualTo("Article"));
        }
 public ActionResult Index(int?pageIndex, int?pageSize, Dictionary entity)
 {
     try
     {
         DictionaryRepository ml = new DictionaryRepository();
         entity.IsDeleted = false;
         PagedList <Dictionary> page = ml.Search(entity).GetPagedList(pageIndex ?? PageIndex, pageSize ?? PageSize, Order, By);
         if (Request.IsAjaxRequest())
         {
             return(PartialView("_Index", page));
         }
         return(View(page));
     }
     catch (Exception ex)
     {
         return(Content(ContentIcon.Error + "|" + ErrorWirter(RouteData, ex.Message)));
     }
 }
Exemple #14
0
        public JsonResult GetTypeByCategoryID(int categoryID)
        {
            DictionaryRepository _repository = new DictionaryRepository();

            var data = _repository.GetTypes(categoryID).ToList();
            List <SelectListItem> list = new List <SelectListItem>();

            foreach (eArchiver.Models.Type type in data)
            {
                list.Add(new SelectListItem()
                {
                    Text  = type.Name,
                    Value = type.TypeID.ToString()
                });
            }

            return(Json(list));
        }
        public void Get_AutocreateNotSet_ReturnFalse([Content] DbItem item, DictionaryRepository repository)
        {
            //Arrange
            var siteContext = new FakeSiteContext(new StringDictionary()
            {
                ["dictionaryPath"] = item.FullPath,
                ["database"]       = "master"
            });

            using (new SiteContextSwitcher(siteContext))
            {
                //Act
                var result = repository.Get(siteContext);

                //Assert
                result.AutoCreate.Should().BeFalse();
            }
        }
        // GET: Equipment
        public ActionResult Index()
        {
            DictionaryRepository dicRepository = new DictionaryRepository(false);

            Guid id = Guid.NewGuid();

            ViewBag.EquipmentLocation =
                dicRepository.GetAsQuarable().Where(o => o.Type == Dictionary.DicEquipmentLab.DicCode && o.ExpireDate == null)
                .ToList().OrderBy(o => o.Name)
                .Select(o => new Item()
            {
                Id = o.Id.ToString(), Name = o.Name
            }).ToList();

            ViewBag.UiId = Guid.NewGuid();

            return(PartialView(id));
        }
        public void Can_Perform_Get_On_DictionaryRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var languageRepository = new LanguageRepository(unitOfWork);
            var repository = new DictionaryRepository(unitOfWork, languageRepository);

            // Act
            var dictionaryItem = repository.Get(1);

            // Assert
            Assert.That(dictionaryItem, Is.Not.Null);
            Assert.That(dictionaryItem.ItemKey, Is.EqualTo("Read More"));
            Assert.That(dictionaryItem.Translations.Any(), Is.True);
            Assert.That(dictionaryItem.Translations.Any(x => x == null), Is.False);
            Assert.That(dictionaryItem.Translations.First().Value, Is.EqualTo("Read More"));
            Assert.That(dictionaryItem.Translations.Last().Value, Is.EqualTo("Læs mere"));
        }
Exemple #18
0
        public void Can_Perform_Get_On_DictionaryRepository()
        {
            // Arrange
            var provider           = new PetaPocoUnitOfWorkProvider();
            var unitOfWork         = provider.GetUnitOfWork();
            var languageRepository = new LanguageRepository(unitOfWork);
            var repository         = new DictionaryRepository(unitOfWork, languageRepository);

            // Act
            var dictionaryItem = repository.Get(1);

            // Assert
            Assert.That(dictionaryItem, Is.Not.Null);
            Assert.That(dictionaryItem.ItemKey, Is.EqualTo("Read More"));
            Assert.That(dictionaryItem.Translations.Any(), Is.True);
            Assert.That(dictionaryItem.Translations.Any(x => x == null), Is.False);
            Assert.That(dictionaryItem.Translations.First().Value, Is.EqualTo("Read More"));
            Assert.That(dictionaryItem.Translations.Last().Value, Is.EqualTo("Læs mere"));
        }
Exemple #19
0
        public void Can_Perform_Delete_On_DictionaryRepository()
        {
            // Arrange
            var provider           = new PetaPocoUnitOfWorkProvider();
            var unitOfWork         = provider.GetUnitOfWork();
            var languageRepository = new LanguageRepository(unitOfWork);
            var repository         = new DictionaryRepository(unitOfWork, languageRepository);

            // Act
            var item = repository.Get(1);

            repository.Delete(item);
            unitOfWork.Commit();

            var exists = repository.Exists(1);

            // Assert
            Assert.That(exists, Is.False);
        }
Exemple #20
0
        /// <summary>
        /// Завантаження данних з довідників
        /// </summary>
        private void LoadComboBox()
        {
            ProfileNames    = new List <string>();
            MilitaryRanks   = new List <string>();
            TypeAccountings = new List <string>();

            using (DictionaryRepository dictionaryRepo = new DictionaryRepository())
            {
                var dic = dictionaryRepo.GetList();

                ProfileNames    = dic.Where(d => d.GroupeName == Enums.ComboBoxName.ProfileName).Select(d => d.ItemName).ToList();
                MilitaryRanks   = dic.Where(d => d.GroupeName == Enums.ComboBoxName.MilitaryRank).Select(d => d.ItemName).ToList();
                TypeAccountings = dic.Where(d => d.GroupeName == Enums.ComboBoxName.TypeAccounting).Select(d => d.ItemName).ToList();
            }
            using (VOSRepository vosRepo = new VOSRepository())
            {
                Vos = vosRepo.GetList();
            }
        }
Exemple #21
0
        static void Seed()
        {
            var GameRepo = new GameRepository();
            var UserRepo = new UserProfileRepository();
            var WordRepo = new WordBankRepository();
            var RoleRepo = new RoleRepository();
            var DicRepo  = new DictionaryRepository();

            DicRepo.AddDictionary(DictionaryList.OrderBy(d => d.Word).Distinct().ToList());
            foreach (var item in Roles)
            {
                RoleRepo.AddRole(item);
            }
            UserRepo.AddUserProfile(UserProfile);
            Console.WriteLine("User Added");
            GameRepo.AddGame(Game);
            Console.WriteLine("Game Added");
            WordRepo.AddWordBank(WordBank);
            Console.WriteLine("Word Added");
        }
Exemple #22
0
        public void Puzzle3Test()
        {
            //Arrange
            IDictionaryRepository dictionaryRepository = new DictionaryRepository();

            ITrieBuilder trieBuilder = new TrieBuilder(dictionaryRepository);

            BoggleWordSearchService boggleWordSearchService = new BoggleWordSearchService(trieBuilder);
            var board           = "FVKOWQIMEZTLRPBE";
            var expectedResults = Solution3Results();

            //Act
            HashSet <string> result = boggleWordSearchService.FindWordsInBoggle(board, 4, 4);

            //only care that tries look the same.
            var resultString   = Newtonsoft.Json.JsonConvert.SerializeObject(result.OrderBy(keys => keys));
            var expectedString = Newtonsoft.Json.JsonConvert.SerializeObject(expectedResults);

            //Assert
            Assert.AreEqual(expectedString, resultString);
        }
Exemple #23
0
        // [Authorize]
        public ActionResult Index(Guid?documentID)
        {
            DictionaryRepository dictRepository = new DictionaryRepository();

            ScanBrowser    scans     = ScanBrowserFactory.Create();
            ScansViewModel viewModel = new ScansViewModel();

            viewModel.AllScansCount   = scans.GetScansCount(true);
            viewModel.KnownScansCount = scans.GetScansCount(false);
            viewModel.AvailableScans  = _repository.GetAvailableScans().ToList();//Context.AvailableScans.OrderByDescending(s=>s.ImportDate).ToList();
            viewModel.Categories      = dictRepository.GetCategories().ToList();
            viewModel.Types2          = dictRepository.GetTypes2().ToList();
            viewModel.Senders         = dictRepository.GetSenders().OrderBy(s => s.LastName).ThenBy(s => s.FirstName).ToList();

            if (documentID.HasValue)
            {
                viewModel.DocumentID = documentID;
            }

            return(View(viewModel));
        }
        public ActionResult Create(int DictionaryTypeID, FormCollection formCollection)
        {
            try
            {
                DictionaryRepository ml = new DictionaryRepository();

                Dictionary obj = new Dictionary()
                {
                    CreateDate = DateTime.Now, CreateUserID = ID, IsDeleted = false
                };

                UpdateModel(obj);

                bool result = ml.Insert(obj) > 0 ? true : false;

                return(result ? Content(ContentIcon.Succeed + "|操作成功|/Admin/Dictionary/Index?DictionaryTypeID=" + DictionaryTypeID) : Content(ContentIcon.Error + "|操作失败"));
            }
            catch (Exception ex)
            {
                return(Content(ContentIcon.Error + "|" + ErrorWirter(RouteData, ex.Message)));
            }
        }
        /// <summary>
        /// Протокол квалификации
        /// </summary>
        /// <param name="id"></param>
        /// <param name="equipmentId"></param>
        /// <returns></returns>
        public PartialViewResult ProtocolOfQualificationForm(Guid?id, Guid?equipmentId)
        {
            ViewBag.UiId = Guid.NewGuid().ToString();

            EquipmentRepository eRepository = new EquipmentRepository();
            LimsEquipmentAct    act         = new LimsEquipmentAct();

            act.Id           = Guid.Empty;
            act.FileLinkData = new FileLink();
            if (equipmentId.HasValue && !id.HasValue)
            {
                var equipment = eRepository.GetAsQuarable(e => e.Id == equipmentId)
                                .FirstOrDefault();
                act.LimsEquipment = equipment;
                act.EquipmentId   = equipmentId.Value;
            }
            else if (id.HasValue)
            {
                act = eRepository.GetLimsEquipmentActs(ea => ea.Id == id).FirstOrDefault();
                if (act != null)
                {
                    act.FileLinkData = eRepository.GetActualActFile(id.Value);
                    if (act.FileLinkData == null)
                    {
                        DictionaryRepository dicRepo = new DictionaryRepository(false);
                        act.FileLinkData            = new FileLink();
                        act.FileLinkData.CategoryId = dicRepo.GetDictionaryElementIdByTypeAndCode(Dictionary.DicEquipmentAct.DicCode,
                                                                                                  Dictionary.DicEquipmentAct.ProtocolOfQualification);
                        act.FileLinkData.DocumentId = act.Id;
                        act.FileLinkData.Id         = Guid.NewGuid();
                    }
                    act.FileLinkData.AcceptFormats =
                        "application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/pdf, image/jpeg";
                }
            }

            return(PartialView("ProtocolOfQualificationView", act));
        }
        public JsonResult SaveProtocolOfQualification(LimsEquipmentAct model)
        {
            string msg = string.Empty;

            ModelState.Remove("Id");
            if (ModelState.IsValid)
            {
                try
                {
                    EquipmentRepository  eRepository = new EquipmentRepository();
                    DictionaryRepository dicRepo     = new DictionaryRepository(false);
                    if (model.Id == Guid.Empty)
                    {
                        model.Id         = Guid.NewGuid();
                        model.CreateDate = DateTime.Now;

                        Guid?actTypeId = dicRepo.GetDictionaryElementIdByTypeAndCode(Dictionary.DicEquipmentAct.DicCode,
                                                                                     Dictionary.DicEquipmentAct.ProtocolOfQualification);
                        if (actTypeId != null)
                        {
                            model.ActTypeId = actTypeId.Value;
                        }

                        eRepository.InsertLimsEquipmentAct(model);
                    }
                    else
                    {
                        eRepository.UpdateLimsEquipmentAct(model);
                    }
                    eRepository.Save();
                }
                catch (Exception e)
                {
                    msg = e.ToString();
                }
            }
            return(Json(new { msg }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult CreateSparePart([DataSourceRequest] DataSourceRequest request,
                                            [Bind(Exclude = "Id")] LimsEquipmentActSparePart model, Guid actId, Guid equipmentId)
        {
            if (ModelState.IsValid)
            {
                EquipmentRepository eRepository = new EquipmentRepository(false);
                var act = eRepository.GetLimsEquipmentActs(a => a.Id == actId).FirstOrDefault();
                if (act == null)
                {
                    act = new LimsEquipmentAct()
                    {
                        Id          = actId,
                        CreateDate  = DateTime.Now,
                        EquipmentId = equipmentId
                    };

                    DictionaryRepository dicRepo = new DictionaryRepository(false);
                    Guid?actTypeId = dicRepo.GetDictionaryElementIdByTypeAndCode(Dictionary.DicEquipmentAct.DicCode,
                                                                                 Dictionary.DicEquipmentAct.ActOfSpareParts);
                    if (actTypeId != null)
                    {
                        act.ActTypeId = actTypeId.Value;
                    }

                    eRepository.InsertLimsEquipmentAct(act);
                    eRepository.Save();
                }
                model.EquipmentActId = act.Id;


                model.Id          = Guid.NewGuid();
                model.CreatedDate = DateTime.Now;

                eRepository.InsertLimsEquipmentActSparePart(model);
                eRepository.Save();
            }
            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult Edit(int id, FormCollection formCollection)
        {
            try
            {
                DictionaryRepository ml = new DictionaryRepository();

                Dictionary obj = ml.GetDictionary(id);

                UpdateModel(obj);

                obj.LastUpdateDate = DateTime.Now;

                obj.LastUpdateUserID = ID;

                bool result = ml.Update(obj) > 0 ? true : false;

                return(result ? Content(ContentIcon.Succeed + "|操作成功") : Content(ContentIcon.Error + "|操作失败"));
            }
            catch (Exception ex)
            {
                return(Content(ContentIcon.Error + "|" + ErrorWirter(RouteData, ex.Message)));
            }
        }
        public JsonResult AcceptDirection(Guid directionId)
        {
            MaterialDirectionRepository repository = new MaterialDirectionRepository(false);
            EXP_MaterialDirections      m          = repository.GetAsQuarable(d => d.Id == directionId).FirstOrDefault();

            if (m != null)
            {
                DictionaryRepository drep = new DictionaryRepository(false);
                var statusId = drep.GetDictionaryElementIdByTypeAndCode(Dictionary.MaterialDirectionStatusDic.DicCode, Dictionary.MaterialDirectionStatusDic.Accepted);
                if (statusId.HasValue)
                {
                    m.StatusId = statusId.Value;
                }

                m.ReceiveDate        = DateTime.Now;
                m.ExecutorEmployeeId = UserHelper.GetCurrentEmployee().Id;

                repository.Update(m);
                repository.Save();
            }

            return(Json(directionId, JsonRequestBehavior.AllowGet));
        }
Exemple #30
0
        public ActionResult MaterialForm(Guid?id)
        {
            DictionaryRepository drepository = new DictionaryRepository(false);

            var mpsampleId =
                drepository.GetAsQuarable(
                    d => d.Type == Dictionary.MaterialRdType.DicCode && d.Code == Dictionary.MaterialRdType.MpSample)
                .Select(d => d.Id)
                .FirstOrDefault();

            EXP_Materials material = new EXP_Materials()
            {
                Id     = Guid.NewGuid(),
                TypeId = mpsampleId,
            };

            if (id.HasValue)
            {
                MaterialRepository repository = new MaterialRepository(false);
                material = repository.GetById(id.Value);
            }

            return(PartialView("_MaterialFormView", material));
        }
        public JsonResult SaveActForRepair(LimsEquipmentAct model)
        {
            string msg = string.Empty;

            ModelState.Remove("Id");
            if (ModelState.IsValid)
            {
                try
                {
                    EquipmentRepository  eRepository = new EquipmentRepository();
                    DictionaryRepository dicRepo     = new DictionaryRepository(false);
                    EmployeesRepository  empRepo     = new EmployeesRepository(false);
                    var act = eRepository.GetLimsEquipmentActs(a => a.Id == model.Id).FirstOrDefault();

                    if (act == null)
                    {
                        model.Id         = Guid.NewGuid();
                        model.CreateDate = DateTime.Now;

                        Guid?actTypeId = dicRepo.GetDictionaryElementIdByTypeAndCode(Dictionary.DicEquipmentAct.DicCode,
                                                                                     Dictionary.DicEquipmentAct.ActForRepair);
                        if (actTypeId != null)
                        {
                            model.ActTypeId = actTypeId.Value;
                        }

                        var headOfLab = empRepo.GetById(model.HeadOfLaboratoryId);
                        if (headOfLab != null)
                        {
                            model.HeadOfLaboratoryName = headOfLab.FullName;
                        }
                        var engineer = empRepo.GetById(model.EngineerId);
                        if (engineer != null)
                        {
                            model.EngineerName = engineer.FullName;
                        }

                        eRepository.InsertLimsEquipmentAct(model);
                    }
                    else
                    {
                        act.State  = model.State;
                        act.Reason = model.Reason;

                        act.HeadOfLaboratoryId = model.HeadOfLaboratoryId;
                        var headOfLab = empRepo.GetById(model.HeadOfLaboratoryId);
                        if (headOfLab != null)
                        {
                            act.HeadOfLaboratoryName = headOfLab.FullName;
                        }

                        act.EngineerId = model.EngineerId;
                        var engineer = empRepo.GetById(model.EngineerId);
                        if (engineer != null)
                        {
                            act.EngineerName = engineer.FullName;
                        }

                        eRepository.UpdateLimsEquipmentAct(act);
                    }

                    eRepository.Save();
                }
                catch (Exception e)
                {
                    msg = e.ToString();
                }
            }
            return(Json(new { msg }, JsonRequestBehavior.AllowGet));
        }
        public void Can_Perform_Delete_On_DictionaryRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var languageRepository = new LanguageRepository(unitOfWork);
            var repository = new DictionaryRepository(unitOfWork, languageRepository);

            // Act
            var item = repository.Get(1);
            repository.Delete(item);
            unitOfWork.Commit();

            var exists = repository.Exists(1);

            // Assert
            Assert.That(exists, Is.False);
        }
        public JsonResult SaveActOfConversation(LimsEquipmentAct model)
        {
            string msg = string.Empty;

            ModelState.Remove("Id");
            if (ModelState.IsValid)
            {
                try
                {
                    EquipmentRepository  eRepository = new EquipmentRepository();
                    DictionaryRepository dicRepo     = new DictionaryRepository(false);
                    EmployeesRepository  empRepo     = new EmployeesRepository(false);
                    if (model.Id == Guid.Empty)
                    {
                        model.Id         = Guid.NewGuid();
                        model.CreateDate = DateTime.Now;

                        Guid?actTypeId = dicRepo.GetDictionaryElementIdByTypeAndCode(Dictionary.DicEquipmentAct.DicCode,
                                                                                     Dictionary.DicEquipmentAct.ActOfConversation);
                        if (actTypeId != null)
                        {
                            model.ActTypeId = actTypeId.Value;
                        }

                        var headOfLab = empRepo.GetById(model.HeadOfLaboratoryId);
                        if (headOfLab != null)
                        {
                            model.HeadOfLaboratoryName = headOfLab.FullName;
                        }
                        var director = empRepo.GetById(model.DirectorRCId);
                        if (director != null)
                        {
                            model.DirectorRCName = director.FullName;
                        }

                        eRepository.InsertLimsEquipmentAct(model);
                    }
                    else
                    {
                        var headOfLab = empRepo.GetById(model.HeadOfLaboratoryId);
                        if (headOfLab != null)
                        {
                            model.HeadOfLaboratoryName = headOfLab.FullName;
                        }
                        var director = empRepo.GetById(model.DirectorRCId);
                        if (director != null)
                        {
                            model.DirectorRCName = director.FullName;
                        }

                        eRepository.UpdateLimsEquipmentAct(model);
                    }
                    eRepository.Save();
                }
                catch (Exception e)
                {
                    msg = e.ToString();
                }
            }
            return(Json(new { msg }, JsonRequestBehavior.AllowGet));
        }
Exemple #34
0
 private IEnumerable <KeyValuePair <string, string> > GetCommunicationPreferencesProperties()
 {
     if (contactProfileProvider.CommunicationProfile.CommunicationRevoked)
     {
         yield return(new KeyValuePair <string, string>(DictionaryRepository.Get("/Demo/PersonalInfo/CommunicationRevoked", "Communication Revoked"), DictionaryRepository.Get("/Demo/PersonalInfo/CommunicationRevokedTrue", "Yes")));
     }
     if (contactProfileProvider.CommunicationProfile.ConsentRevoked)
     {
         yield return(new KeyValuePair <string, string>(DictionaryRepository.Get("/Demo/PersonalInfo/ConsentRevokes", "Consent Revoked"), DictionaryRepository.Get("/Demo/PersonalInfo/ConsentRevokedTrue", "Yes")));
     }
     if (!string.IsNullOrEmpty(contactProfileProvider.Preferences.Language))
     {
         yield return(new KeyValuePair <string, string>(DictionaryRepository.Get("/Demo/PersonalInfo/PreferredLanguage", "Preferred Language"), contactProfileProvider.Preferences.Language));
     }
 }
        public void Can_Perform_GetByQuery_On_DictionaryRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var languageRepository = new LanguageRepository(unitOfWork);
            var repository = new DictionaryRepository(unitOfWork, languageRepository);

            // Act
            var query = Query<IDictionaryItem>.Builder.Where(x => x.ItemKey == "Article");
            var result = repository.GetByQuery(query);

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Any(), Is.True);
            Assert.That(result.FirstOrDefault().ItemKey, Is.EqualTo("Article"));
        }
        public void Can_Perform_Update_On_DictionaryRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var languageRepository = new LanguageRepository(unitOfWork);
            var repository = new DictionaryRepository(unitOfWork, languageRepository);

            // Act
            var item = repository.Get(1);
            var translations = item.Translations.ToList();
            translations[0].Value = "Read even more";
            item.Translations = translations;

            repository.AddOrUpdate(item);
            unitOfWork.Commit();

            var dictionaryItem = repository.Get(1);

            // Assert
            Assert.That(dictionaryItem, Is.Not.Null);
            Assert.That(dictionaryItem.Translations.Count(), Is.EqualTo(2));
            Assert.That(dictionaryItem.Translations.FirstOrDefault().Value, Is.EqualTo("Read even more"));
        }
 private DictionaryRepository CreateRepository(IDatabaseUnitOfWork unitOfWork, out LanguageRepository languageRepository)
 {
     languageRepository = new LanguageRepository(unitOfWork, NullCacheProvider.Current);
     var dictionaryRepository = new DictionaryRepository(unitOfWork, NullCacheProvider.Current, languageRepository);
     return dictionaryRepository;
 }
        public void Can_Perform_Add_On_DictionaryRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var languageRepository = new LanguageRepository(unitOfWork);
            var repository = new DictionaryRepository(unitOfWork, languageRepository);

            var language = languageRepository.Get(1);

            var read = new DictionaryItem("Read");
            var translations = new List<IDictionaryTranslation>
                                   {
                                       new DictionaryTranslation(language, "Read")
                                   };
            read.Translations = translations;

            // Act
            repository.AddOrUpdate(read);
            unitOfWork.Commit();

            var exists = repository.Exists(read.Id);

            // Assert
            Assert.That(read.HasIdentity, Is.True);
            Assert.That(exists, Is.True);
        }
        public void Can_Perform_Count_On_DictionaryRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var languageRepository = new LanguageRepository(unitOfWork);
            var repository = new DictionaryRepository(unitOfWork, languageRepository);

            // Act
            var query = Query<IDictionaryItem>.Builder.Where(x => x.ItemKey.StartsWith("Read"));
            var result = repository.Count(query);

            // Assert
            Assert.That(result, Is.EqualTo(1));
        }
        public void Can_Perform_Exists_On_DictionaryRepository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var languageRepository = new LanguageRepository(unitOfWork);
            var repository = new DictionaryRepository(unitOfWork, languageRepository);

            // Act
            var exists = repository.Exists(1);

            // Assert
            Assert.That(exists, Is.True);
        }