protected void buttonCreateScholarshipCommittee_Click(object sender, EventArgs e)
        {
            try
            {
                var newScholarshipCommittee = new CreateNewScholarshipCommitteeDTO();

                if (!string.IsNullOrWhiteSpace(ScholarshipCommittee_Password.Text) && !string.IsNullOrWhiteSpace(ScholarshipCommittee_Password2.Text))
                {
                    if (ScholarshipCommittee_Password.Text != ScholarshipCommittee_Password2.Text)
                    {
                        throw new Exception("Şifre bilgisi uyuşmuyor!");
                    }
                }

                newScholarshipCommittee.UserTypeId    = (int)EnumUserType.ScholarshipCommittee;
                newScholarshipCommittee.FirstName     = ScholarshipCommittee_FirstName.Text;
                newScholarshipCommittee.LastName      = ScholarshipCommittee_LastName.Text;
                newScholarshipCommittee.BirthDate     = ScholarshipCommittee_BirthDate.SelectedDate.Value;
                newScholarshipCommittee.PhoneNum      = ScholarshipCommittee_Phone.Text;
                newScholarshipCommittee.Title         = ScholarshipCommittee_Title.Text;
                newScholarshipCommittee.Username      = ScholarshipCommittee_TCKN.Text;
                newScholarshipCommittee.Email         = ScholarshipCommittee_Email.Text;
                newScholarshipCommittee.Password      = ScholarshipCommittee_Password.Text;
                newScholarshipCommittee.Password      = ScholarshipCommittee_Password.Text;
                newScholarshipCommittee.DutyStartDate = ScholarshipCommittee_DutyStartDate.SelectedDate.Value;

                ServiceResult <long> serviceResult = new ServiceResult <long>();
                var queryString = new Dictionary <string, string>();
                var response    = ApiHelper.CallSendApiMethod(ApiKeys.AccountApiUrl, "CreateNewScholarshipCommittee", queryString, newScholarshipCommittee);
                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception("Hata oluştu!");
                }
                var data = response.Content.ReadAsStringAsync().Result;
                serviceResult = JsonConvert.DeserializeObject <ServiceResult <long> >(data);

                if (serviceResult.ServiceResultType != EnumServiceResultType.Success)
                {
                    throw new Exception(serviceResult.ErrorMessage);
                }

                labelErrorMessage.Text    = "Burs komitesi üyeliği oluşturuldu.";
                labelErrorMessage.Visible = true;
            }
            catch (Exception ex)
            {
                labelErrorMessage.Text    = ex.Message;
                labelErrorMessage.Visible = true;
            }
        }
コード例 #2
0
        public ServiceResult <long> CreateNewScholarshipCommittee(CreateNewScholarshipCommitteeDTO model)
        {
            string errorMessage = string.Empty;
            EnumServiceResultType serviceResultType = EnumServiceResultType.Unspecified;
            long result = -1;

            try
            {
                var anyExistingUser = _userRepository.Entities.Any(p => p.Username == model.Username && p.Email == model.Email && p.IsActive);

                if (anyExistingUser)
                {
                    throw new Exception("Kullanıcı bilgisi mevcut.");
                }

                var newUser = new Contracts.Entities.EF.User
                {
                    IsActive   = true,
                    Password   = model.Password,
                    Username   = model.Username,
                    UserTypeId = model.UserTypeId,
                    Email      = model.Email
                };

                var newScholarshipCommittee = new ScholarshipCommittee
                {
                    FirstName   = model.FirstName,
                    LastName    = model.LastName,
                    PhoneNumber = model.PhoneNum,
                    Title       = model.Title
                };

                newUser.ScholarshipCommittee.Add(newScholarshipCommittee);

                var userResult = _userRepository.Add(newUser);
                _unitOfWork.SaveChanges();

                result            = userResult.Id;
                serviceResultType = EnumServiceResultType.Success;
            }
            catch (Exception ex)
            {
                errorMessage      = ex.Message;
                serviceResultType = EnumServiceResultType.Error;
            }
            return(new ServiceResult <long> {
                ErrorMessage = errorMessage, Result = result, ServiceResultType = serviceResultType
            });
        }
コード例 #3
0
        public IHttpActionResult CreateNewScholarshipCommittee(CreateNewScholarshipCommitteeDTO model)
        {
            if (!Request.Headers.Contains("apiKey"))
            {
                return(Unauthorized());
            }

            string apiKey = Request.Headers.GetValues("apiKey").First();

            if (!ApiHelper.CheckKey(apiKey))
            {
                return(Unauthorized());
            }

            try
            {
                var serviceResult = _accountService.CreateNewScholarshipCommittee(model);
                return(Ok(serviceResult));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }