Exemplo n.º 1
0
        public ActionResult Edit(int?Id)
        {
            var InternalNotifications = InternalNotificationsRepository.GetInternalNotificationsById(Id.Value);

            if (InternalNotifications != null && InternalNotifications.IsDeleted != true)
            {
                var model = new InternalNotificationsViewModel();
                AutoMapper.Mapper.Map(InternalNotifications, model);
                //if (model.CreatedUserId != Helpers.Common.CurrentUser.Id && Helpers.Common.CurrentUser.UserTypeId != 1)
                //{
                //    TempData["FailedMessage"] = "NotOwner";
                //    return RedirectToAction("Index");
                //}

                return(View(model));
            }
            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public ActionResult Detail(int?Id)
        {
            Session["file"] = null;
            var DocumentField = DocumentFieldRepository.GetvwDocumentFieldById(Id.Value);
            var path          = Helpers.Common.GetSetting(DocumentField.Category);

            if (DocumentField != null && DocumentField.IsDeleted != true)
            {
                var model = new DocumentFieldViewModel();
                AutoMapper.Mapper.Map(DocumentField, model);
                if (model.Category == "Contract")
                {
                    var q = contractRepository.GetContractById(model.CategoryId);
                    if (q != null)
                    {
                        model.CategoryDetail = q.Code;
                    }
                }
                else if (model.Category == "LabourContract")
                {
                    var q = labourContractRepository.GetLabourContractById(model.CategoryId);
                    if (q != null)
                    {
                        model.CategoryDetail = q.Name;
                    }
                }
                else if (model.Category == "InternalNotifications")
                {
                    var q = InternalNotificationsRepository.GetInternalNotificationsById(model.CategoryId);
                    if (q != null)
                    {
                        model.CategoryDetail = q.Titles;
                    }
                }
                //model.PositionName = categoryRepository.GetCategoryByCode("position").Where(x => x.Value == model.IsSearch).FirstOrDefault().Name;
                model.DocumentAttributeList = DocumentAttributeRepository.GetAllDocumentAttribute().Where(x => x.DocumentFieldId == Id)
                                              .Select(item => new DocumentAttributeViewModel
                {
                    Id            = item.Id,
                    CreatedUserId = item.CreatedUserId,
                    //CreatedUserName = item.CreatedUserName,
                    CreatedDate    = item.CreatedDate,
                    ModifiedUserId = item.ModifiedUserId,
                    //ModifiedUserName = item.ModifiedUserName,
                    ModifiedDate = item.ModifiedDate,
                    File         = item.File,
                    Note         = item.Note,
                    OrderNo      = item.OrderNo,
                    Size         = item.Size,
                    TypeFile     = item.TypeFile
                }).OrderByDescending(x => x.CreatedDate).ToList();
                foreach (var item in model.DocumentAttributeList)
                {
                    if (item.TypeFile.Equals("jpeg") || item.TypeFile.Equals("jpg") || item.TypeFile.Equals("png") || item.TypeFile.Equals("gif"))
                    {
                        item.FilePath = path + item.File;
                    }
                    else
                    {
                        item.FilePath = "/assets/file-icons-upload/48px/" + item.TypeFile + ".png";
                    }
                    item.QuantityDownload = LogDocumentAttributeRepositorty.GetAllLogDocumentAttribute().Where(x => x.DocumentAttributeId == item.Id).Count();
                }
                return(View(model));
            }
            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            return(RedirectToAction("Index"));
        }