Exemplo n.º 1
0
        public async Task<ActionResult> Add(TechnicalStaffViewModel technicalStaffModel)
        {
            var canAddTechnicalStaff = await _participationService
                .CanAddTechnicalStaff(technicalStaffModel.ParticipationId, Convert.ToInt32(User.Identity.Name));

            if (!canAddTechnicalStaff)
            {
                ModelState.AddModelError("", "امکان درج کادر فنی جدید وجود ندارد.");
                return this.JsonValidationErrors();
            }

            var tmpPath = Server.MapPath("~/App_Data/tmp/");

            var fullName = string.Format("{0}-{1}", technicalStaffModel.FirstName, technicalStaffModel.LastName).ApplyCorrectYeKe();

            if (technicalStaffModel.Id == 0)
            {

                var userImagePath = Server.MapPath("~/App_Data/TechnicalStaff_Image/");

                await
                    CopyFileAsync(tmpPath + technicalStaffModel.Image,
                        userImagePath + string.Format("{0}-{1}", fullName, technicalStaffModel.Image));

                technicalStaffModel.Image = string.Format("{0}-{1}", fullName, technicalStaffModel.Image);
            }

            var technicalStaff = new DomainClasses.TechnicalStaff
            {
                FirstName = technicalStaffModel.FirstName,
                BirthDate = technicalStaffModel.BirthDate,
                FatherName = technicalStaffModel.FatherName,
                Image = technicalStaffModel.Image,
                LastName = technicalStaffModel.LastName,
                NationalCode = technicalStaffModel.NationalCode,
                Id = technicalStaffModel.Id
            };

            var similarParticipationIds =
                await _participationService.GetSimilarParticipationSport(technicalStaffModel.ParticipationId,
                Convert.ToInt32(User.Identity.Name));

            foreach (var participationId in similarParticipationIds)
            {
                _technicalStaffService.Add(technicalStaff, participationId, technicalStaffModel.TechnicalStaffRoleId);
            }

            await _dbContext.SaveChangesAsync();

            return new HttpStatusCodeResult(HttpStatusCode.OK);
        }
        public async Task <ActionResult> Add(TechnicalStaffViewModel technicalStaffModel)
        {
            var canAddTechnicalStaff = await _participationService
                                       .CanAddTechnicalStaff(technicalStaffModel.ParticipationId, Convert.ToInt32(User.Identity.Name));

            if (!canAddTechnicalStaff)
            {
                ModelState.AddModelError("", "امکان درج کادر فنی جدید وجود ندارد.");
                return(this.JsonValidationErrors());
            }

            var tmpPath = Server.MapPath("~/App_Data/tmp/");

            var fullName = string.Format("{0}-{1}", technicalStaffModel.FirstName, technicalStaffModel.LastName).ApplyCorrectYeKe();

            if (technicalStaffModel.Id == 0)
            {
                var userImagePath = Server.MapPath("~/App_Data/TechnicalStaff_Image/");

                await
                CopyFileAsync(tmpPath + technicalStaffModel.Image,
                              userImagePath + string.Format("{0}-{1}", fullName, technicalStaffModel.Image));

                technicalStaffModel.Image = string.Format("{0}-{1}", fullName, technicalStaffModel.Image);
            }

            var technicalStaff = new DomainClasses.TechnicalStaff
            {
                FirstName    = technicalStaffModel.FirstName,
                BirthDate    = technicalStaffModel.BirthDate,
                FatherName   = technicalStaffModel.FatherName,
                Image        = technicalStaffModel.Image,
                LastName     = technicalStaffModel.LastName,
                NationalCode = technicalStaffModel.NationalCode,
                Id           = technicalStaffModel.Id
            };

            var similarParticipationIds =
                await _participationService.GetSimilarParticipationSport(technicalStaffModel.ParticipationId,
                                                                         Convert.ToInt32(User.Identity.Name));

            foreach (var participationId in similarParticipationIds)
            {
                _technicalStaffService.Add(technicalStaff, participationId, technicalStaffModel.TechnicalStaffRoleId);
            }

            await _dbContext.SaveChangesAsync();

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
Exemplo n.º 3
0
        // GET: TechnicalStaff/UserPanel
        public async Task<ActionResult> Add(TechnicalStaffViewModel technicalStaffModel, int competitionId)
        {
            var canAddTechnicalStaff = await _competitionService
               .CanAddCommonTechnicalStaff(competitionId, Convert.ToInt32(User.Identity.Name));

            if (!canAddTechnicalStaff)
            {
                ModelState.AddModelError("", "امکان درج کادر اجرایی جدید وجود ندارد.");
                return this.JsonValidationErrors();
            }


            var tmpPath = Server.MapPath("~/App_Data/tmp/");


            var fullName = string.Format("{0}-{1}", technicalStaffModel.FirstName, technicalStaffModel.LastName).ApplyCorrectYeKe();


            var userImagePath = Server.MapPath("~/App_Data/TechnicalStaff_Image/");

            await
                CopyFileAsync(tmpPath + technicalStaffModel.Image,
                    userImagePath + string.Format("{0}-{1}", fullName, technicalStaffModel.Image));

            technicalStaffModel.Image = string.Format("{0}-{1}", fullName, technicalStaffModel.Image);


            var technicalStaff = new DomainClasses.TechnicalStaff
            {
                FirstName = technicalStaffModel.FirstName,
                BirthDate = technicalStaffModel.BirthDate,
                FatherName = technicalStaffModel.FatherName,
                Image = technicalStaffModel.Image,
                LastName = technicalStaffModel.LastName,
                NationalCode = technicalStaffModel.NationalCode,
                Id = technicalStaffModel.Id,
                MobileNumber = technicalStaffModel.MobileNumber
            };

            _commonTechnicalStaffService.Add(technicalStaff, Convert.ToInt32(User.Identity.Name),
                competitionId,
                technicalStaffModel.TechnicalStaffRoleId);

            await _dbContext.SaveChangesAsync();

            return new HttpStatusCodeResult(HttpStatusCode.OK);
        }
Exemplo n.º 4
0
        // GET: TechnicalStaff/UserPanel
        public async Task <ActionResult> Add(TechnicalStaffViewModel technicalStaffModel, int competitionId)
        {
            var canAddTechnicalStaff = await _competitionService
                                       .CanAddCommonTechnicalStaff(competitionId, Convert.ToInt32(User.Identity.Name));

            if (!canAddTechnicalStaff)
            {
                ModelState.AddModelError("", "امکان درج کادر اجرایی جدید وجود ندارد.");
                return(this.JsonValidationErrors());
            }


            var tmpPath = Server.MapPath("~/App_Data/tmp/");


            var fullName = string.Format("{0}-{1}", technicalStaffModel.FirstName, technicalStaffModel.LastName).ApplyCorrectYeKe();


            var userImagePath = Server.MapPath("~/App_Data/TechnicalStaff_Image/");

            await
            CopyFileAsync(tmpPath + technicalStaffModel.Image,
                          userImagePath + string.Format("{0}-{1}", fullName, technicalStaffModel.Image));

            technicalStaffModel.Image = string.Format("{0}-{1}", fullName, technicalStaffModel.Image);


            var technicalStaff = new DomainClasses.TechnicalStaff
            {
                FirstName    = technicalStaffModel.FirstName,
                BirthDate    = technicalStaffModel.BirthDate,
                FatherName   = technicalStaffModel.FatherName,
                Image        = technicalStaffModel.Image,
                LastName     = technicalStaffModel.LastName,
                NationalCode = technicalStaffModel.NationalCode,
                Id           = technicalStaffModel.Id,
                MobileNumber = technicalStaffModel.MobileNumber
            };

            _commonTechnicalStaffService.Add(technicalStaff, Convert.ToInt32(User.Identity.Name),
                                             competitionId,
                                             technicalStaffModel.TechnicalStaffRoleId);

            await _dbContext.SaveChangesAsync();

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
 public void Edit(DomainClasses.TechnicalStaff technicalStaff)
 {
     _technicalStaffs.Attach(technicalStaff);
     _dbContext.Entry(technicalStaff).State = EntityState.Modified;
 }