//public List<TypeMasterVM> GetAllTypes()
        //{
        //    var typeList = _TypeRepository.GetAll(x => x.IsDeleted == false);
        //    List<TypeMasterVM> typeVMList = new List<TypeMasterVM>();
        //    foreach (var item in typeList)
        //    {
        //        TypeMasterVM typeVM = new TypeMasterVM();
        //        typeVM.Type = item.Type;
        //        typeVM.TypeId = item.TypeId;
        //        typeVMList.Add(typeVM);
        //    }
        //    return typeVMList;
        //}

        //public List<TypeMasterVM> GetAllTypes(PagingVM pageparam)
        //{
        //    PagingVM1 param = new PagingVM1();
        //    param.page = pageparam.page;
        //    param.PageSize = pageparam.pageSize;
        //    var typeList = _TypeRepository.GetAll(param, x => x.TypeId,x=>x.IsDeleted==false);

        //    List<TypeMasterVM> typeVMList = new List<TypeMasterVM>();
        //    if (typeList != null)
        //    {
        //        foreach (var item in typeList.ToList())
        //        {
        //            TypeMasterVM typeVM = new TypeMasterVM();
        //            typeVM.Type = item.Type;
        //            typeVM.TypeId = item.TypeId;
        //            typeVMList.Add(typeVM);
        //        }
        //    }
        //    return typeVMList;
        //}

        public TypeMasterVM GetByIdType(int id)
        {
            var          type   = _TypeRepository.GetById(id);
            TypeMasterVM typeVM = new TypeMasterVM();

            typeVM.Type   = type.Type;
            typeVM.TypeId = type.TypeId;
            return(typeVM);
        }
        public IEnumerable <ItemMasterVM> GetAllItems()
        {
            try
            {
                var ItemListVM = _ItemRepository.GetAll().Where(x => x.IsDeleted == false)
                                 .Select(n => new ItemMasterVM
                {
                    BatchNo        = n.BatchNo,
                    Description    = n.Description,
                    HSN            = n.HSN,
                    IsActive       = (bool)n.IsActive,
                    ItemCode       = n.ItemCode,
                    ItemId         = n.ItemId,
                    ItemName       = n.ItemName,
                    UOM            = _IUnitRepository.GetById((long)n.UOMId).abbreviation,
                    TypeName       = _ITypeRepository.GetById((long)n.TypeId).Type,
                    ManufacturedBy = n.ManufacturedBy,
                    Price          = n.Price,
                    SerialNo       = n.SerialNo,
                });

                return(ItemListVM);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #3
0
        public virtual void CreateSemanticNetworkFromNodeCandidates(
            [NotNull] IReadOnlyCollection <NodeCandidate> nodeCandidates,
            [NotNull] SessionOfExperts sessionOfExperts)
        {
            if (nodeCandidates == null)
            {
                throw new ArgumentNullException(nameof(nodeCandidates));
            }
            if (sessionOfExperts == null)
            {
                throw new ArgumentNullException(nameof(sessionOfExperts));
            }

            var generalVergeType = _relationTypeRepository.GetGeneralType();
            var generalNodeType  = _notionTypeRepository.GetGeneralType();

            var root = GetOrCreateNode(sessionOfExperts.BaseNotion, generalNodeType, sessionOfExperts);

            _nodeRepository.AddOrUpdate(root);

            foreach (var nodeCandidate in nodeCandidates.Where(x => x.IsSaveAsNode))
            {
                var node = GetOrCreateNode(
                    nodeCandidate.Notion,
                    _notionTypeRepository.GetById(nodeCandidate.TypeId),
                    sessionOfExperts);
                _nodeRepository.AddOrUpdate(node);

                var straightVerge = UpdateOrCreateVerge(root, node, generalVergeType, nodeCandidate.ExpertPercent, sessionOfExperts);
                var reverseVerge  = UpdateOrCreateVerge(node, root, generalVergeType, nodeCandidate.ExpertPercent, sessionOfExperts);

                _vergeRepository.AddOrUpdate(straightVerge);
                _vergeRepository.AddOrUpdate(reverseVerge);
            }
        }
Exemple #4
0
        /// <summary>
        /// Sets types for associations of expert.
        /// </summary>
        /// <param name="associations">List of plain objects, that contains id of association and its type.</param>
        /// <param name="expertName">Expert name.</param>
        /// <param name="sessionOfExperts">Session of experts.</param>
        public virtual void AssociationsTypes(
            [NotNull] IReadOnlyCollection <AssociationDto> associations,
            [NotNull] string expertName,
            [NotNull] SessionOfExperts sessionOfExperts)
        {
            if (associations == null)
            {
                throw new ArgumentNullException(nameof(associations));
            }
            if (expertName == null)
            {
                throw new ArgumentNullException(nameof(expertName));
            }
            if (sessionOfExperts == null)
            {
                throw new ArgumentNullException(nameof(sessionOfExperts));
            }

            var expert = GetExpertByNameAndSession(expertName, sessionOfExperts, ExpertFetch.Associations);

            IfExpertDoesNotExistThrow(expert, expertName, sessionOfExperts);

            foreach (var association in associations)
            {
                var typeNode = _notionTypeRepository.GetById(association.TypeId);

                // ReSharper disable once PossibleNullReferenceException
                expert.SetTypeForAssociation(association.Id, typeNode, association.OfferType);
            }

            // ReSharper disable once AssignNullToNotNullAttribute
            _expertRepository.AddOrUpdate(expert);
        }
        public void Should_Get_Type_By_Id_Return_Type_Object()
        {
            Type typeAux = _typeRepository.GetAll().FirstOrDefault();

            Type type = _typeRepository.GetById(typeAux.TypeId);

            Assert.IsInstanceOfType(type, typeof(Type));
        }
        public void UpdateType(TypeViewModel type)
        {
            Type entity = _typeRepository.GetById <int>(type.Id);

            Map(type, entity);
            _typeRepository.Update(entity);
            _unitOfWork.SaveChanges();
        }
        public void DeleteType(TypeViewModel type)
        {
            Type selectedType = _typeRepository.GetById <int>(type.Id);

            selectedType.Status = (int)DbConstant.DefaultDataStatus.Deleted;
            _typeRepository.Update(selectedType);
            _unitOfWork.SaveChanges();
        }
Exemple #8
0
        public ActionResult Add(CropAndAddMultimediaObjectViewModel Model)
        {
            if (ModelState.IsValid)
            {
                if (string.IsNullOrEmpty(Model.MultimediaObject.Url))
                {
                    ModelState.AddModelError("MultimediaObject.Url", "Podanie Adresu URL jest wymagane!");
                    var tt =
                        _typeRespository.Types.Select(it => new { Value = it.Id, Text = it.Name + " szer: " + it.Width + "px wys: " + it.Height + "px" });
                    Model.MultimediaTypes = new SelectList(tt, "Value", "Text");
                    return(View(Model));
                }

                int          cropPointX = Model.x; int cropPointY = Model.y; int imageCropWidth = Model.w; int imageCropHeight = Model.h;
                MemoryStream target = new MemoryStream();
                Model.inputFile.InputStream.CopyTo(target);
                byte[] imageBytes = target.ToArray();
                byte[] croppedImage;
                if (imageCropHeight > 0 && imageCropWidth > 0)
                {
                    croppedImage = ImageHelper.CropImage(imageBytes, cropPointX, cropPointY, imageCropWidth, imageCropHeight);
                }
                else
                {
                    croppedImage = imageBytes;
                }

                ADServerDAL.Models.Type type = _typeRespository.GetById((int)Model.MultimediaObject.TypeId);
                croppedImage = ImageProcesorHelper.ResizeImage(type.Width, type.Height, croppedImage, false).ResizedImage;

                MultimediaObject image = new MultimediaObject
                {
                    Contents  = croppedImage,
                    Content   = croppedImage,
                    FileName  = Model.inputFile.FileName,
                    MimeType  = Model.inputFile.ContentType,
                    TypeId    = Model.MultimediaObject.TypeId,
                    Name      = Model.MultimediaObject.Name,
                    UserId    = User.GetUserIDInt(),
                    Url       = Model.MultimediaObject.Url,
                    Campaigns = Model.MultimediaObject.Campaigns
                };

                if (image.UserId == 0 || (!User.IsInRole("Admin") && User.GetUserIDInt() != image.UserId))
                {
                    image.UserId = User.GetUserIDInt();
                }

                _repository.Save(image, Model.MultimediaObject.Campaigns.ToList());

                return(RedirectToAction("Index"));
            }
            var t =
                _typeRespository.Types.Select(it => new { Value = it.Id, Text = it.Name + " szer: " + it.Width + "px wys: " + it.Height + "px" });

            Model.MultimediaTypes = new SelectList(t, "Value", "Text");
            return(View(Model));
        }
        public IActionResult Details(int id)
        {
            dynamic model = new ExpandoObject();

            model.BookList      = bookRepository.GetById(id);
            model.AuthorList    = authorRepository.GetById(model.BookList.AuthorId);
            model.TypeList      = typeRepository.GetById(model.BookList.TypeId);
            model.PublisherList = publisherRepository.GetById(model.BookList.PublisherId);
            model.LanguageList  = languageRepository.GetById(model.BookList.LanguageId);
            return(View(model));
        }
Exemple #10
0
        public ValidationResult Handler(CreateMessageCommand command)
        {
            Message message = new Message(command.Sentence, command.TypeId, command.Title);

            Type type = _typeRepository.GetById(command.TypeId);

            RuleFor(m => m.Type).NotNull().WithMessage("The Type is empty or nullable");

            //1-I need implement a validation to repository
            Boolean result = _messageRepository.Create(message);

            return(Validate(message));
        }
 public async Task <Type> GetById(User user, Guid id)
 {
     try
     {
         var type = _typeRepository.GetById(id);
         if ((type.fk_UserId == user.Id || type.fk_UserId == null) && !type.Deleted)
         {
             return(type);
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemple #12
0
        public ActionResult Edit(int?id)
        {
            var ids = User.GetUserIDInt();
            var u   = _usersRepository.Users.Single(it => it.Id == ids);

            ViewBag.AdPoints = u.AdPoints;

            // Pobierz typ z repozytorium
            var type = _repository.GetById(id ?? 0);

            // Zbuduj i zwróć model
            var viewModel = new MultimediaTypeViewMode
            {
                MultimediaType = type ?? new ADServerDAL.Models.Type()
            };

            return(View(viewModel));
        }
        public IActionResult PieChart()
        {
            var books = bookRepository.GetAll();
            //PASTA GRAFİĞİ TÜRÜNE GÖRE
            var allCategory             = typeRepository.GetAll();
            List <DataPoint> dataPoints = new List <DataPoint>();

            var readedBook = books.Where(i => i.isReaded == true).Count();

            for (int i = 1; i <= allCategory.Count(); i++)
            {
                var category = typeRepository.GetById(i);
                int book     = books.Where(a => a.isReaded == true).Where(a => a.TypeId == i).Count();
                int rate     = 100 * book / readedBook;
                dataPoints.Add(new DataPoint(category.Name, rate));
            }
            ViewBag.DataPoints = JsonConvert.SerializeObject(dataPoints);
            //PASTA GRAFİĞİ TÜRÜNE GÖRE SON
            return(View());
        }
        /// <summary>
        /// Metoda ładująca plik na serwer
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage Upload()
        {
            var    errors     = "";
            object result     = null;
            var    serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

            try
            {
                ///Sprawdź czy w żądaniu znajduje się informacja o przesyłanym pliku
                if (HttpContext.Current.Request.Files != null && HttpContext.Current.Request.Files.Count > 0 &&
                    HttpContext.Current.Request.Params["MultimediaObjectTypeId"] != null)
                {
                    ///Pobierz pierwszy znaleziony plik
                    HttpPostedFile file = HttpContext.Current.Request.Files[0];

                    if (file.ContentType.ToUpper().StartsWith("IMAGE/"))
                    {
                        if (file.ContentLength > 0)
                        {
                            ///na formularzu, z którego przychodzi request muszą być pola o dokładnie takich nazwach:
                            var typeIdString = HttpContext.Current.Request.Params["MultimediaObjectTypeId"].ToString();
                            int typeId       = 0;
                            int.TryParse(typeIdString, out typeId);
                            serializer.MaxJsonLength = GetJsonMaxLength();
                            byte[] contents = null;

                            ///Utwórz tablicę bajtów dla przesyłanego pliku
                            using (var memoryStream = new MemoryStream())
                            {
                                file.InputStream.CopyTo(memoryStream);
                                contents = memoryStream.ToArray();
                            }

                            ///Pobierz informacje o typie obiektu multimedialnego
                            ADServerDAL.Models.Type objType = typeRepository.GetById(typeId);
                            if (objType == null)
                            {
                                throw new Exception("Nie można odnaleść żadanego typu obiektu. Możliwe zmiany na innym stanowisku.");
                            }

                            ///Odczytaj docelowe wymiary obrazu
                            var width  = objType.Width;
                            var height = objType.Height;

                            try
                            {
                                ///Zmień rozmiar przesłanego obrazu na podstawie wymiarów typu obiektu
                                contents = ImageProcesorHelper.ResizeImage(width, height, contents, false).ResizedImage;
                            }
                            catch (Exception)
                            {
                                errors += "Plik jest uszkodzony lub ma niewłaściwy typ. ";
                                throw;
                            }

                            HttpContext.Current.Response.ContentType = "text/plain";

                            ///Sprawdź czy plik po zmianie rozmiaru ma dopuszczalny rozmiar
                            if (contents.Length <= serializer.MaxJsonLength)
                            {
                                result = new
                                {
                                    name     = file.FileName,
                                    contents = Convert.ToBase64String(contents),
                                    mimeType = file.ContentType,
                                    width    = width,
                                    height   = height
                                };
                            }
                            else
                            {
                                errors += string.Format("Plik jest zbyt duży. Maksymalny rozmiar pliku to {0}B. ", serializer.MaxJsonLength);
                            }
                        }
                    }
                    else
                    {
                        errors += string.Format("Plik ma nieprawidłowy format ({0})", file.ContentType);
                    }
                }
                else
                {
                    errors += "Brak pliku lub brak parametru MultimediaObjectTypeId. ";
                }
            }
            catch (Exception ex)
            {
                errors += string.Format("Komunikat błędu: {0} (Źródło: {1})", ex.Message, ex.Source);;
            }

            if (errors != null && errors.Length > 0)
            {
                result = new { errors = errors };
            }

            ///Zapisz zmodyfikowany plik jako JSON i zwróć do klienta
            HttpContext.Current.Response.Write(serializer.Serialize(result));
            HttpContext.Current.Response.StatusCode = 200;
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
        public async Task <TypeViewModel> GetById(int id)
        {
            var data = await _typeServiceRepository.GetById(id);

            return(data.ToModel());
        }
Exemple #16
0
 public EnterType GetById(int id)
 {
     return(_typeRepository.GetById(id));
 }
Exemple #17
0
 public IActionResult Delete(int id)
 {
     return(View(typeRepository.GetById(id)));
 }
 public void deleteType(int id)
 {
     Data.Type Type = TypeRepository.GetById(id);
     TypeRepository.Delete(Type);
     SaveChange();
 }
        public TypeViewModel GetById(Guid typeId)
        {
            Type type = _typeRepository.GetById(typeId);

            return(new TypeViewModel(type.TypeId, type.Definicion, type.Icon));
        }
 public async Task <Type> GetById(int id)
 {
     return(await _typeRepository.GetById(id));
 }