Ejemplo n.º 1
0
        public ActionResult Edit(string ATE, string A)
        {
            NullChecker.NullCheck(new object[] { ATE, A });
            var    ate = EncryptionHelper.Unprotect(ATE);
            var    a   = EncryptionHelper.Unprotect(A);
            Answer answerEntryToEdit = unitOfWork.AnswerRepository.GetByID(EncryptionHelper.Unprotect(ATE));

            if (AuthorizationHelper.isRelevant(answerEntryToEdit.answererID) && ate == a)
            {
                if (TryUpdateModel(answerEntryToEdit, "", new string[] { "answerBody" }))
                {
                    if (!String.IsNullOrWhiteSpace(answerEntryToEdit.answerBody))
                    {
                        unitOfWork.AnswerRepository.Update(answerEntryToEdit);
                        unitOfWork.Save();
                    }
                    UnitOfWork editContext = new UnitOfWork();
                    var        answer      = editContext.AnswerRepository.GetByID(answerEntryToEdit.answerID);
                    return(Json(new
                    {
                        Result = RenderPartialViewHelper.RenderPartialView(this, "AnswerDetailPartial", answer),
                        Message = Resource.Resource.editedSuccessfully
                    }));
                }
                throw new ModelStateException(this.ModelState);
            }
            throw new JsonCustomException(ControllerError.ajaxErrorAnswerEdit);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(string CoId, string company, string Cats)
        {
            NullChecker.NullCheck(new object[] { CoId, company });

            var coToEdit = unitOfWork.NotExpiredCompanyRepository
                           .GetByID(EncryptionHelper.Unprotect(CoId));

            if (coToEdit.Admins.Any(g => AuthorizationHelper.isRelevant(g.UserId)))
            {
                if (ModelState.IsValid)
                {
                    if (TryUpdateModel(coToEdit, "", new string[] {
                        "coName", "coNameEN", "about", "aboutEN",
                        "companySize", "stateID", "countryCode", "stateCode", "regCode", "iranCode",
                        "phoneNo", "faxNo", "email", "website", "address", "addressEN"
                    }))
                    {
                        UpSertCompanyCats(Cats, coToEdit);

                        unitOfWork.CompanyRepository.Update(coToEdit);
                        unitOfWork.Save();
                        UrlHelper Url = new UrlHelper(Request.RequestContext);
                        return(Json(new { URL = Url.Action("CProfile", "Company", new { CoId = coToEdit.coID, CoName = StringHelper.URLName(coToEdit.CultureCoName) }) }));
                    }
                }
                throw new ModelStateException(this.ModelState);
            }
            throw new JsonCustomException(ControllerError.ajaxError);
        }
Ejemplo n.º 3
0
        public ActionResult Delete(string Q, string QTD)
        {
            NullChecker.NullCheck(new object[] { QTD, Q });
            var      qtd = EncryptionHelper.Unprotect(QTD);
            var      q   = EncryptionHelper.Unprotect(Q);
            Question questionToDelete = unitOfWork.QuestionRepository
                                        .GetByID(qtd);

            if (qtd == q && AuthorizationHelper.isRelevant(questionToDelete.questionerID))
            {
                unitOfWork.LikeCommentRepository.Get(d => questionToDelete.Comments.Select(f => f.cmtID).Contains(d.elemID) && d.type == LikeCommentType.Question).ToList().ForEach(unitOfWork.LikeCommentRepository.Delete);
                //questionToDelete.Comments.SelectMany(t => t.Likes.Select(l => l.likeID as object)).ToList().ForEach(unitOfWork.LikeRepository.Delete); //QuestionCommentsLikesDelete
                questionToDelete.Comments.Select(t => t.cmtID as object).ToList().ForEach(unitOfWork.CommentQuestionRepository.Delete); //QuestionCommentsDelete
                questionToDelete.Likes.Select(l => l.likeID as object).ToList().ForEach(unitOfWork.LikeQuestionRepository.Delete);      //QuestionLikesDelete
                unitOfWork.LikeCommentRepository.Get(d => questionToDelete.Answers.SelectMany(f => f.Comments.Select(h => h.cmtID)).Contains(d.elemID) && d.type == LikeCommentType.Question).ToList().ForEach(unitOfWork.LikeCommentRepository.Delete);
                //questionToDelete.Answers.SelectMany(t => t.Comments.SelectMany(l => l.Likes.Select(g => g.likeID as object))).ToList().ForEach(unitOfWork.LikeRepository.Delete); //QuestionAnswersCommentsLikesDelete
                questionToDelete.Answers.SelectMany(t => t.Likes.Select(l => l.likeID as object)).ToList().ForEach(unitOfWork.LikeAnswerRepository.Delete);      //QuestionAnswersLikesDelete
                questionToDelete.Answers.SelectMany(t => t.Comments.Select(l => l.cmtID as object)).ToList().ForEach(unitOfWork.CommentAnswerRepository.Delete); //QuestionAnswersCommentsDelete
                questionToDelete.Answers.Select(l => l.answerID as object).ToList().ForEach(unitOfWork.AnswerRepository.Delete);                                 //QuestionLikesDelete
                //questionToDelete.Notifications.Select(n => n.notificationID as object).ToList().ForEach(unitOfWork.NotificationRepository.Delete);//QuestionNotificationsDelete

                var fileUploadResult = UploadHelper.UpdateUploadedFiles(String.Empty, questionToDelete.image + questionToDelete.docuoment, "Question");
                if (String.IsNullOrEmpty(fileUploadResult.ImagesToUpload) && String.IsNullOrEmpty(fileUploadResult.DocsToUpload))
                {
                    unitOfWork.QuestionRepository.Delete(questionToDelete);
                    unitOfWork.Save();
                }
                return(Json(new { Success = true, RedirectURL = Url.Action("TotalSearch", "Home", new { searchType = SearchType.Question }) }));
            }
            throw new JsonCustomException(ControllerError.ajaxErrorQuestionDelete);
        }
Ejemplo n.º 4
0
        public ActionResult Delete(string P, string PTD)
        {
            NullChecker.NullCheck(new object[] { PTD, P });
            var     ptd             = EncryptionHelper.Unprotect(PTD);
            var     p               = EncryptionHelper.Unprotect(P);
            Product productToDelete = unitOfWork.ProductRepository
                                      .GetByID(ptd);

            if (!productToDelete.company.Admins.Any(u => AuthorizationHelper.isRelevant(u.UserId)))
            {
                return(new RedirectToError());
            }

            if (ptd == p && productToDelete.company.Admins.Any(u => AuthorizationHelper.isRelevant(u.UserId)))
            {
                unitOfWork.LikeCommentRepository.Get(d => productToDelete.Comment.Select(f => f.cmtID).Contains(d.elemID) && d.type == LikeCommentType.Product).ToList().ForEach(unitOfWork.LikeCommentRepository.Delete);
                //productToDelete.Comment.SelectMany(t => t.Likes.Select(l => l.likeID as object)).ToList().ForEach(unitOfWork.LikeRepository.Delete); //ProductCommentsLikesDelete
                productToDelete.Comment.Select(t => t.cmtID as object).ToList().ForEach(unitOfWork.CommentProductRepository.Delete); //ProductCommentsDelete
                productToDelete.Likes.Select(l => l.likeID as object).ToList().ForEach(unitOfWork.LikeProductRepository.Delete);     //ProductLikesDelete
                //productToDelete.Notifications.Select(n => n.notificationID as object).ToList().ForEach(unitOfWork.NotificationRepository.Delete);//ProductNotificationsDelete

                var fileUploadResult = UploadHelper.UpdateUploadedFiles(String.Empty, productToDelete.image + productToDelete.document, "Question");
                if (String.IsNullOrEmpty(fileUploadResult.ImagesToUpload) && String.IsNullOrEmpty(fileUploadResult.DocsToUpload))
                {
                    unitOfWork.ProductRepository.Delete(productToDelete);
                    unitOfWork.Save();
                }
                UrlHelper Url = new UrlHelper(Request.RequestContext);
                return(Json(new { URL = Url.Action("CompanyProducts", "Product", new { CoId = productToDelete.coID }) }));
            }
            throw new JsonCustomException(ControllerError.ajaxErrorProductDelete);
        }
Ejemplo n.º 5
0
        public ActionResult Edit(FormCollection formCollection, string STE, string S)
        {
            NullChecker.NullCheck(new object[] { STE, S });

            var   ste = EncryptionHelper.Unprotect(STE);
            var   s   = EncryptionHelper.Unprotect(S);
            Share shareEntryToEdit = unitOfWork.ShareRepository.GetByID(ste);

            if (AuthorizationHelper.isRelevant((int)shareEntryToEdit.SharerUserID) &&
                ste == s)
            {
                if (TryUpdateModel(shareEntryToEdit, "", new string[] { "shareNote" }))
                {
                    unitOfWork.ShareRepository.Update(shareEntryToEdit);
                    unitOfWork.Save();

                    return(Json(new
                    {
                        Message = Resource.Resource.editedSuccessfully,
                        Note = Resource.Resource.shareNote + ": " + shareEntryToEdit.shareNote
                    }));
                }
                throw new ModelStateException(this.ModelState);
            }
            throw new JsonCustomException(ControllerError.ajaxErrorPostEdit);
        }
Ejemplo n.º 6
0
        public ActionResult Create(string CoId)
        {
            NullChecker.NullCheck(new object[] { CoId });

            var curentCompany = unitOfWork.NotExpiredCompanyRepository
                                .GetByID(EncryptionHelper.Unprotect(CoId));

            if (curentCompany == null ||
                !curentCompany.Admins.Any(u => AuthorizationHelper.isRelevant(u.UserId)))
            {
                return(new RedirectToError());
            }
            CountriesViewModel countries = new CountriesViewModel();

            ViewBag.CountryDropDown = countries.countries;


            //PorT SelectList
            var PorTs = from PorT e in Enum.GetValues(typeof(PorT))
                        select new { Id = e, Name = Resource.EnumTypes.ResourceManager.GetString(e.ToString()) };

            ViewBag.portDropdown = new SelectList(PorTs, "Id", "Name");

            ViewData["company"] = CoId;

            return(View());
        }
Ejemplo n.º 7
0
        public ActionResult Edit(string PrId)
        {
            NullChecker.NullCheck(new object[] { PrId });

            var productToEdit = unitOfWork.ProductRepository
                                .GetByID(EncryptionHelper.Unprotect(PrId));

            if (productToEdit.company is CompanyExpired ||
                !productToEdit.company.Admins.Any(u => AuthorizationHelper.isRelevant(u.UserId)))
            {
                return(new RedirectToError());
            }

            CountriesViewModel countries = new CountriesViewModel();

            ViewBag.CountryDropDown = countries.countries;


            //PorT SelectList
            var PorTs = from PorT e in Enum.GetValues(typeof(PorT))
                        select new { Id = e, Name = Resource.EnumTypes.ResourceManager.GetString(e.ToString()) };

            ViewBag.portDropdown = new SelectList(PorTs, "Id", "Name");

            ViewData["product"] = PrId;
            var catss = productToEdit.categories.Select(u => u.catID);

            ViewData["Cats"] = String.Join(",", catss);
            return(View(productToEdit));
        }
Ejemplo n.º 8
0
 public Module(RegionManager regionManager, IUnityContainer container)
 {
     NullChecker.IsObjectInitialized(regionManager);
     NullChecker.IsObjectInitialized(container);
     _regionManager = regionManager;
     _container     = container;
 }
Ejemplo n.º 9
0
        public async Task <IEnumerable <T> > GetEntities <T>(string partitionKey) where T : ITableEntity, new()
        {
            if (_table == null)
            {
                await CheckForTableAsync();
            }
            NullChecker.IsNotNull(partitionKey, nameof(partitionKey));

            try
            {
                TableQuerySegment <T> querySegment = null;
                var entities = new List <T>();
                var query    = new TableQuery <T>().Where(TableQuery.GenerateFilterCondition(nameof(ITableEntity.PartitionKey), QueryComparisons.Equal, partitionKey));

                do
                {
                    querySegment = await _table.ExecuteQuerySegmentedAsync(query, querySegment?.ContinuationToken);

                    entities.AddRange(querySegment.Results);
                } while (querySegment.ContinuationToken != null);

                return(entities);
            }
            catch (Exception e)
            {
                _logger.LogError(e.HResult, e, "Retrieve from table failed");
                throw;
            }
        }
Ejemplo n.º 10
0
        public ActionResult EditAdvInfo(string UId, FormCollection form)
        {
            NullChecker.NullCheck(new object[] { UId });
            var uid = EncryptionHelper.Unprotect(UId);

            if (!AuthorizationHelper.isRelevant((int)uid))
            {
                throw new JsonCustomException(ControllerError.ajaxError);
            }
            var userToEdit = unitOfWork.ActiveUserRepository.GetByID(uid);

            if (userToEdit.melliCode != null)
            {
                if (TryUpdateModel(userToEdit, "", new string[] { "mobile" }))
                {
                    unitOfWork.ActiveUserRepository.Update(userToEdit);
                    unitOfWork.Save();
                    UrlHelper Url = new UrlHelper(Request.RequestContext);
                    return(Json(new { URL = Url.Action("UProfile", "UserProfile", new { UId = userToEdit.UserId, UName = StringHelper.URLName(userToEdit.CultureFullName) }) }));
                }
            }
            else
            {
                if (TryUpdateModel(userToEdit, "", new string[] { "mobile", "melliCode" }))
                {
                    unitOfWork.ActiveUserRepository.Update(userToEdit);
                    unitOfWork.Save();
                    UrlHelper Url = new UrlHelper(Request.RequestContext);
                    return(Json(new { URL = Url.Action("UProfile", "UserProfile", new { UId = userToEdit.UserId, UName = StringHelper.URLName(userToEdit.CultureFullName) }) }));
                }
            }
            throw new ModelStateException(this.ModelState);
        }
Ejemplo n.º 11
0
        public ActionResult Edit(string patID, FormCollection formCollection)
        {
            NullChecker.NullCheck(new object[] { patID });

            Patent patentEntryToEdit = unitOfWork.PatentRepository
                                       .GetByID(EncryptionHelper.Unprotect(patID));

            if (!patentEntryToEdit.Inventors.Any(i => AuthorizationHelper.isRelevant(i.UserId)))
            {
                throw new JsonCustomException(ControllerError.ajaxErrorPatentUser);
            }
            if (TryUpdateModel(patentEntryToEdit, "", new string[] { "status", "officeStateID", "patentTitle", "patentTitleEN", "patentNo", "patentURL", "issueDate", "description", "descriptionEN" }))
            {
                unitOfWork.PatentRepository.Update(patentEntryToEdit);
                unitOfWork.Save();
                UnitOfWork newContext   = new UnitOfWork();
                var        editedPatent = newContext.PatentRepository.GetByID(patentEntryToEdit.patentID);
                return(Json(new
                {
                    Result = RenderPartialViewHelper.RenderPartialView(this, "PatentPartial", editedPatent),
                    Message = Resource.Resource.editedSuccessfully
                }));
            }
            throw new ModelStateException(this.ModelState);
        }
Ejemplo n.º 12
0
        public ActionResult EditInfo(string UId, string professionTags)
        {
            NullChecker.NullCheck(new object[] { UId });
            var uid = EncryptionHelper.Unprotect(UId);

            if (!AuthorizationHelper.isRelevant((int)uid))
            {
                throw new JsonCustomException(ControllerError.ajaxError);
            }
            var userToEdit = unitOfWork.ActiveUserRepository.GetByID(uid);

            if (TryUpdateModel(userToEdit, "", new string[] {
                "firstName", "firstNameEN", "lastName", "lastNameEN",
                "about", "aboutEN", "stateID", "birthDay"
            }))
            {
                UpdSertUserProffs(professionTags, userToEdit);

                unitOfWork.ActiveUserRepository.Update(userToEdit);
                unitOfWork.Save();
                UrlHelper Url = new UrlHelper(Request.RequestContext);
                return(Json(new { URL = Url.Action("UProfile", "UserProfile", new { UId = userToEdit.UserId, UName = StringHelper.URLName(userToEdit.CultureFullName) }) }));
            }
            throw new ModelStateException(this.ModelState);
        }
Ejemplo n.º 13
0
        public ActionResult AnswerAccept(string AId)
        {
            NullChecker.NullCheck(new object[] { AId });
            var answer = unitOfWork.AnswerRepository.GetByID(EncryptionHelper.Unprotect(AId));

            if (AuthorizationHelper.isRelevant(answer.Question.questionerID))
            {
                if (answer.accept)
                {
                    answer.accept = false;
                    unitOfWork.AnswerRepository.Update(answer);
                    unitOfWork.Save();
                    return(Json(new { Success = true, Result = false }));
                }
                else
                {
                    answer.accept = true;
                    unitOfWork.Save();
                    unitOfWork.AnswerRepository.Update(answer);
                    NotificationHelper.NotificationInsert(NotificationType.AnswerAccept,
                                                          elemId: answer.answerID);
                    FeedHelper.FeedInsert(FeedType.AnswerAccept,
                                          answer.questionID,
                                          answer.answererID
                                          );
                    ScoreHelper.Update(new ScoreVars {
                        type   = ScoreType.Aacc,
                        elemId = answer.answerID,
                        sign   = 1
                    });
                    return(Json(new { Success = true, Result = true }));
                }
            }
            throw new JsonCustomException(ControllerError.ajaxErrorAnswerAcception);
        }
Ejemplo n.º 14
0
        public ActionResult Delete([Bind(Include = "A,answerID")] Answer answerToDelet, string ATD, string A, string U)
        {
            NullChecker.NullCheck(new object[] { ATD, A, U });

            this.ModelState.Remove("answerBody");
            var atd = EncryptionHelper.Unprotect(ATD);
            var a   = EncryptionHelper.Unprotect(A);

            if (atd == a && AuthorizationHelper.isRelevant((int)EncryptionHelper.Unprotect(U)))
            {
                if (ModelState.IsValid)
                {
                    var answerToDelete = unitOfWork.AnswerRepository.GetByID(EncryptionHelper.Unprotect(ATD));
                    unitOfWork.LikeCommentRepository.Get(d => answerToDelete.Comments.Select(f => f.cmtID).Contains(d.elemID) && d.type == LikeCommentType.Answer).ToList().ForEach(unitOfWork.LikeCommentRepository.Delete);
                    //answerToDelete.Comments.SelectMany(t => t.Likes.Select(l => l.likeID as object)).ToList().ForEach(unitOfWork.LikeRepository.Delete); //answerCommentsLikesDelete
                    answerToDelete.Comments.Select(t => t.cmtID as object).ToList().ForEach(unitOfWork.CommentAnswerRepository.Delete); //answerCommentsDelete
                    answerToDelete.Likes.Select(l => l.likeID as object).ToList().ForEach(unitOfWork.LikeAnswerRepository.Delete);      //answerLikesDelete
                    //answerToDelete.Notifications.Select(n => n.notificationID as object).ToList().ForEach(unitOfWork.NotificationRepository.Delete);//AnswerNotificationsDelete

                    unitOfWork.AnswerRepository.Delete(EncryptionHelper.Unprotect(ATD));

                    unitOfWork.Save();
                    return(Json(new { Message = Resource.Resource.deletedSuccessfully }));
                }
                throw new ModelStateException(this.ModelState);
            }
            throw new JsonCustomException(ControllerError.ajaxErrorAnswerDelete);
        }
 public HomeController(IHttpContextAccessor contextAccessor, ITrackerEntryService tableService)
 {
     NullChecker.IsNotNull(contextAccessor, nameof(contextAccessor));
     NullChecker.IsNotNull(tableService, nameof(tableService));
     _contextAccessor = contextAccessor;
     _tableService    = tableService;
 }
Ejemplo n.º 16
0
        public async Task <T> InsertOrMergeEntityAsync <T>(T entity) where T : TableEntity
        {
            if (_table == null)
            {
                await CheckForTableAsync();
            }
            NullChecker.IsNotNull(entity, nameof(entity));

            try
            {
                // Create the InsertOrReplace table operation
                TableOperation insertOrMergeOperation = TableOperation.InsertOrMerge(entity);

                // Execute the operation.
                TableResult result = await _table.ExecuteAsync(insertOrMergeOperation);

                _logger.LogTrace("Inserting record into table");

                var InsertedEntity = result.Result as T;

                return(InsertedEntity);
            }
            catch (Exception e)
            {
                _logger.LogError(e.HResult, e, "Insert Or Merge into table failed");
                throw;
            }
        }
Ejemplo n.º 17
0
 private void Awake()
 {
     _rb                = (Rigidbody)NullChecker.TryGet <Rigidbody>(gameObject);
     _rb.constraints    = RigidbodyConstraints.FreezePositionZ;
     _rb.freezeRotation = true;
     _rb.useGravity     = false;
 }
Ejemplo n.º 18
0
        public async Task <T> RetrieveEnitityAsync <T>(T entity) where T : TableEntity
        {
            if (_table == null)
            {
                await CheckForTableAsync();
            }
            NullChecker.IsNotNull(entity, nameof(entity));

            try
            {
                TableOperation retrieveOperation = TableOperation.Retrieve <T>(entity.PartitionKey, entity.RowKey);

                TableResult result = await _table.ExecuteAsync(retrieveOperation);

                _logger.LogTrace("Retrieving record from table");

                var retrieveEntity = result.Result as T;

                return(retrieveEntity);
            }
            catch (Exception e)
            {
                _logger.LogError(e.HResult, e, "Retrieve from table failed");
                throw;
            }
        }
Ejemplo n.º 19
0
        public ActionResult Create([Bind(Include = "productName,productNameEN,brandName,brandNameEN,about,aboutEN,PorT,productionCountryID,weight,height,width,length,power,shabnam,iranCode,packCount,price,shipFree,wuarantee,guarantee,afterSale")] Product product,
                                   string CoId, string company, string filesToUpload, string Cats)
        {
            NullChecker.NullCheck(new object[] { CoId, company });
            var coid  = EncryptionHelper.Unprotect(CoId);
            var comid = EncryptionHelper.Unprotect(company);

            if (ModelState.IsValid)
            {
                var currentUser    = WebSecurity.CurrentUserId;
                var currenyCompany = unitOfWork.NotExpiredCompanyRepository
                                     .GetByID(comid);
                if (coid == comid && currenyCompany.Admins.Any(u => AuthorizationHelper.isRelevant(u.UserId)))
                {
                    product.regDate = DateTime.UtcNow;
                    product.coID    = currenyCompany.coID;
                    unitOfWork.ProductRepository.Insert(product);
                    UpdSertProductCats(Cats, product);
                    unitOfWork.Save();

                    var fileUploadResult = UploadHelper.UpdateUploadedFiles(filesToUpload, String.Empty, "Product");
                    product.image    = fileUploadResult.ImagesToUpload;
                    product.document = fileUploadResult.DocsToUpload;

                    unitOfWork.ProductRepository.Update(product);
                    unitOfWork.Save();
                    UrlHelper Url = new UrlHelper(Request.RequestContext);
                    return(Json(new { URL = Url.Action("Detail", "Product", new { PrId = product.productID }), PrName = StringHelper.URLName(product.CultureProductName) }));
                }
                throw new JsonCustomException(ControllerError.ajaxErrorProductAdmin);
            }
            throw new ModelStateException(this.ModelState);
        }
Ejemplo n.º 20
0
 public TableService(ITableContext tableContext, IGithubService githubService)
 {
     NullChecker.IsNotNull(tableContext, nameof(tableContext));
     NullChecker.IsNotNull(githubService, nameof(githubService));
     _tableContext  = tableContext;
     _githubService = githubService;
 }
Ejemplo n.º 21
0
        public ActionResult Edit(string PrId, string product, string filesToUpload, string Cats)
        {
            NullChecker.NullCheck(new object[] { PrId, product });

            var productToEdit = unitOfWork.ProductRepository
                                .GetByID(EncryptionHelper.Unprotect(PrId));

            if (TryUpdateModel(productToEdit, "", new string[] {
                "productName", "productNameEN", "brandName", "brandNameEN", "about", "aboutEN",
                "PorT", "productionCountryID", "weight", "height", "width", "length",
                "power", "shabnam", "iranCode", "packCount", "price",
                "shipFree", "wuarantee", "guarantee", "afterSale"
            }))
            {
                if (productToEdit.company.Admins.Any(g => AuthorizationHelper.isRelevant(g.UserId)))
                {
                    UpdSertProductCats(Cats, productToEdit);

                    var fileUploadResult = UploadHelper.UpdateUploadedFiles(filesToUpload, productToEdit.image + productToEdit.document, "Product");
                    productToEdit.image    = fileUploadResult.ImagesToUpload;
                    productToEdit.document = fileUploadResult.DocsToUpload;

                    unitOfWork.ProductRepository.Update(productToEdit);
                    unitOfWork.Save();
                    UrlHelper Url = new UrlHelper(Request.RequestContext);
                    return(Json(new { URL = Url.Action("Detail", "Product", new { PrId = productToEdit.productID, PrName = StringHelper.URLName(productToEdit.CultureProductName) }) }));
                }
                throw new JsonCustomException(ControllerError.ajaxErrorProductAdmin);
            }
            throw new ModelStateException(this.ModelState);
        }
Ejemplo n.º 22
0
        public ActionResult Edit(string StId, string store, string Cats)
        {
            NullChecker.NullCheck(new object[] { StId, store });
            var stid    = EncryptionHelper.Unprotect(StId);
            var storeid = EncryptionHelper.Unprotect(store);

            var stToEdit = unitOfWork.StoreNotExpiredRepository
                           .GetByID(stid);

            if (!stToEdit.Admins.Any(c => AuthorizationHelper.isRelevant(c.UserId)))
            {
                throw new JsonCustomException(ControllerError.ajaxError);
            }
            if (stid == storeid)
            {
                if (TryUpdateModel(stToEdit, "", new string[] {
                    "storeName", "storeNameEN", "about", "aboutEN",
                    "stateID", "countryCode", "stateCode", "regCode", "iranCode",
                    "phoneNo", "faxNo", "email", "website", "address", "addressEN"
                }))
                {
                    UpSertStoreCats(Cats, stToEdit);

                    unitOfWork.StoreNotExpiredRepository.Update(stToEdit);
                    unitOfWork.Save();
                    UrlHelper Url = new UrlHelper(Request.RequestContext);
                    return(Json(new { URL = Url.Action("SProfile", "Store", new { StId = stToEdit.storeID, StName = StringHelper.URLName(stToEdit.CultureStoreName) }) }));
                }

                throw new ModelStateException(this.ModelState);
            }
            throw new JsonCustomException(ControllerError.ajaxError);
        }
Ejemplo n.º 23
0
        public ActionResult Share(ShareViewModel newShareToInsert, string PId)
        {
            NullChecker.NullCheck(new object[] { PId });
            int user        = WebSecurity.CurrentUserId;
            int pid         = (int)EncryptionHelper.Unprotect(PId);
            var postToshare = unitOfWork.PostRepository.GetByID(pid);

            if (postToshare.Shares.Any(ts => ts.SharerUserID == user))
            {
                throw new JsonCustomException(ControllerError.ajaxErrorPatentUser);
            }
            if (ModelState.IsValid)
            {
                Share finalshareToInsrt = newShareToInsert.Share;
                finalshareToInsrt.SharerUserID = user;
                finalshareToInsrt.sharedPostID = postToshare.postID;
                finalshareToInsrt.shareNote    = newShareToInsert.Share.shareNote;
                finalshareToInsrt.insertdate   = DateTime.UtcNow;
                unitOfWork.ShareRepository.Insert(finalshareToInsrt);
                unitOfWork.Save();
                FeedHelper.FeedInsert(FeedType.SessionOfferLike, postToshare.postID, WebSecurity.CurrentUserId);
                return(Json(new { Success = true, Message = Resource.Resource.sharedSuccessfully }));
            }
            throw new ModelStateException(this.ModelState);
        }
Ejemplo n.º 24
0
        public ActionResult GetTime(string SnId)
        {
            NullChecker.NullCheck(new object[] { SnId });
            var sem = unitOfWork.SeminarRepository.GetByID(EncryptionHelper.Unprotect(SnId));

            return(Json(new { time = sem.date.AddMinutes(sem.duration).Subtract(DateTime.UtcNow).Minutes }));
        }
Ejemplo n.º 25
0
        public ActionResult Edit(string CoId)
        {
            NullChecker.NullCheck(new object[] { CoId });

            var CoToEdit = unitOfWork.NotExpiredCompanyRepository
                           .GetByID(EncryptionHelper.Unprotect(CoId));

            if (!CoToEdit.Admins.Any(c => AuthorizationHelper.isRelevant(c.UserId)))
            {
                return(new RedirectToNotFound());
            }

            CountriesViewModel countries = new CountriesViewModel();

            ViewBag.CountryDropDown = countries.counts(CoToEdit.State);
            ViewBag.StateDropDown   = countries.states(CoToEdit.State);

            //PorT SelectList
            var PorTs = from CompanySize e in Enum.GetValues(typeof(CompanySize))
                        select new { Id = e, Name = Resource.EnumTypes.ResourceManager.GetString(e.ToString()) };

            ViewBag.CoSizeDropdown = new SelectList(PorTs, "Id", "Name");

            var catss = CoToEdit.Categories.Select(u => u.catID);

            ViewData["Cats"]    = String.Join(",", catss);
            ViewData["company"] = CoId;

            return(View(CoToEdit));
        }
Ejemplo n.º 26
0
        public ActionResult Edit(string eduID, FormCollection formCollection)
        {
            NullChecker.NullCheck(new object[] { eduID });

            Education eduEntryToEdit = unitOfWork.EducationRepository
                                       .GetByID(EncryptionHelper.Unprotect(eduID));

            if (!AuthorizationHelper.isRelevant(eduEntryToEdit.userID))
            {
                throw new JsonCustomException(ControllerError.ajaxErrorEducationUser);
            }

            if (TryUpdateModel(eduEntryToEdit, "", new string[] { "degree", "fieldOfStudy", "fieldOfStudyEN", "school", "schoolEN", "attendDate", "untilDate" }))
            {
                unitOfWork.EducationRepository.Update(eduEntryToEdit);
                unitOfWork.Save();
                UnitOfWork newContext      = new UnitOfWork();
                var        editedEducation = newContext.EducationRepository.GetByID(eduEntryToEdit.educationID);
                return(Json(new
                {
                    Result = RenderPartialViewHelper.RenderPartialView(this, "EducationPartial", editedEducation),
                    Message = Resource.Resource.editedSuccessfully
                }));
            }
            throw new ModelStateException(this.ModelState);
        }
Ejemplo n.º 27
0
        public ActionResult Edit(FormCollection formCollection, string professionTags, string QID, string filesToUpload)
        {
            NullChecker.NullCheck(new object[] { QID });

            var questionToUpdate = unitOfWork.QuestionRepository
                                   .GetByID(EncryptionHelper.Unprotect(QID));

            if (!AuthorizationHelper.isRelevant(questionToUpdate.questionerID))
            {
                return(new RedirectToError());
            }
            if (AuthorizationHelper.isRelevant(questionToUpdate.questionerID))
            {
                if (TryUpdateModel(questionToUpdate, "", new string[] { "questionBody", "questionSubject", "language" }))
                {
                    UpdSertQuestionProffs(professionTags, questionToUpdate);

                    unitOfWork.QuestionRepository.Update(questionToUpdate);
                    unitOfWork.Save();

                    var fileUploadResult = UploadHelper.UpdateUploadedFiles(filesToUpload, questionToUpdate.image + questionToUpdate.docuoment, "Question");
                    questionToUpdate.image     = fileUploadResult.ImagesToUpload;
                    questionToUpdate.docuoment = fileUploadResult.DocsToUpload;

                    unitOfWork.QuestionRepository.Update(questionToUpdate);
                    unitOfWork.Save();

                    return(Json(new { Success = true, URL = Url.Action("Detail", "Question", new { QId = questionToUpdate.questionID, QName = StringHelper.URLName(questionToUpdate.questionSubject) }) }));
                }
                throw new ModelStateException(this.ModelState);
            }
            throw new JsonCustomException(ControllerError.ajaxErrorQuestionAdmin);
        }
Ejemplo n.º 28
0
        public void TryFind_TwoArguments_AlwaysReturnsComponent()
        {
            var result = (IGameController)NullChecker
                         .TryFind <GameController>(null, null);

            Assert.That(result, Is.TypeOf <GameController>());
        }
Ejemplo n.º 29
0
        public ActionResult Delete([Bind(Include = "C,certID")] Certificate certToDelet, string CertID, string C, string U, string CY)
        {
            NullChecker.NullCheck(new object[] { CertID, C });
            var certid = EncryptionHelper.Unprotect(CertID);
            var c      = EncryptionHelper.Unprotect(C);

            if (certid == c)
            {
                var cy = EncryptionHelper.Unprotect(CY);
                if (cy != null &&
                    unitOfWork.CompanyRepository.GetByID(cy).Admins.Any(t => AuthorizationHelper.isRelevant(t.UserId)))
                {
                    unitOfWork.CertificateRepository.Delete(certid);
                    unitOfWork.Save();
                    return(Json(new { Message = Resource.Resource.deletedSuccessfully }));
                }
                else if (AuthorizationHelper.isRelevant((int)EncryptionHelper.Unprotect(U)))
                {
                    unitOfWork.CertificateRepository.Delete(certid);
                    unitOfWork.Save();
                    return(Json(new { Message = Resource.Resource.deletedSuccessfully }));
                }
            }
            throw new ModelStateException(this.ModelState);
        }
Ejemplo n.º 30
0
        public ActionResult Delete(string S, string STD)
        {
            NullChecker.NullCheck(new object[] { STD, S });
            var     std             = EncryptionHelper.Unprotect(STD);
            var     s               = EncryptionHelper.Unprotect(S);
            Service serviceToDelete = unitOfWork.ServiceRepository.GetByID(std);

            if (std == s && serviceToDelete.company.Admins.Any(u => AuthorizationHelper.isRelevant(u.UserId)))
            {
                //unitOfWork.LikeCommentRepository.Get(d => d.type == LikeCommentType.Service && serviceToDelete.Comment.Select(t => t.cmtID).Contains(d.elemID)).ToList().ForEach(unitOfWork.LikeCommentRepository.Delete);
                unitOfWork.LikeCommentRepository.Get(d => serviceToDelete.Comment.Select(f => f.cmtID).Contains(d.elemID) && d.type == LikeCommentType.Service).ToList().ForEach(unitOfWork.LikeCommentRepository.Delete);
                //serviceToDelete.Comment.Select(t => t.cmtID).ToList().ForEach(unitOfWork.LikeCommentRepository.Delete); //ProductCommentsLikesDelete
                serviceToDelete.Comment.Select(t => t.cmtID as object).ToList().ForEach(unitOfWork.CommentServiceRepository.Delete); //ProductCommentsDelete
                serviceToDelete.Likes.Select(l => l.likeID as object).ToList().ForEach(unitOfWork.LikeServiceRepository.Delete);     //ProductLikesDelete
                //serviceToDelete.Notifications.Select(n => n.notificationID as object).ToList().ForEach(unitOfWork.NotificationRepository.Delete);//ProductNotificationsDelete

                var fileUploadResult = UploadHelper.UpdateUploadedFiles(String.Empty, serviceToDelete.image + serviceToDelete.document, "Question");
                if (String.IsNullOrEmpty(fileUploadResult.ImagesToUpload) && String.IsNullOrEmpty(fileUploadResult.DocsToUpload))
                {
                    unitOfWork.ServiceRepository.Delete(serviceToDelete);
                    unitOfWork.Save();
                }
                UrlHelper Url = new UrlHelper(Request.RequestContext);
                return(Json(new { URL = Url.Action("CompanyServices", "Service", new { CoId = serviceToDelete.coID }) }));
            }
            throw new JsonCustomException(ControllerError.ajaxErrorProductDelete);
        }