protected void ScheduleList_AppointmentDelete(object sender, AppointmentDeleteEventArgs e)
        {
            var existingProjectDetailActivitySchedule = new UpdateProjectDetailActivityScheduleDTO();

            existingProjectDetailActivitySchedule.ProjectDetailActivityScheduleId = Convert.ToInt64(e.Appointment.ID.ToString());
            existingProjectDetailActivitySchedule.OperationTypeId = (int)EnumProjectDetailActivityScheduleOperationType.Delete;

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

                if (serviceResult.ServiceResultType != EnumServiceResultType.Success)
                {
                    throw new Exception(serviceResult.ErrorMessage);
                }
            }
            catch (Exception ex)
            {
            }
        }
Пример #2
0
        public IHttpActionResult UpdateProjectDetailActivitySchedule(UpdateProjectDetailActivityScheduleDTO model)
        {
            if (!Request.Headers.Contains("apiKey"))
            {
                return(Unauthorized());
            }

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

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

            try
            {
                var serviceResult = _projectService.UpdateProjectDetailActivitySchedule(model);
                return(Ok(serviceResult));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        protected void ScheduleList_AppointmentCommand(object sender, AppointmentCommandEventArgs e)
        {
            if (e.CommandName == "Insert")
            {
                RadDropDownList activityDropDownList = (RadDropDownList)e.Container.FindControl("ActivityList");

                RadTimePicker startTime = (RadTimePicker)e.Container.FindControl("StartTime");
                RadTimePicker endTime   = (RadTimePicker)e.Container.FindControl("EndTime");

                var selectedDate = e.Container.Appointment.Start;

                DateTime startDateTime = new DateTime(selectedDate.Year, selectedDate.Month, selectedDate.Day, startTime.SelectedTime.Value.Hours, startTime.SelectedTime.Value.Minutes, startTime.SelectedTime.Value.Seconds);
                DateTime endDateTime   = new DateTime(selectedDate.Year, selectedDate.Month, selectedDate.Day, endTime.SelectedTime.Value.Hours, endTime.SelectedTime.Value.Minutes, endTime.SelectedTime.Value.Seconds);

                var newProjectDetailActivitySchedule = new UpdateProjectDetailActivityScheduleDTO();
                newProjectDetailActivitySchedule.ProjectDetailId         = Convert.ToInt64(ProjectDetailName.SelectedValue);
                newProjectDetailActivitySchedule.ProjectDetailActivityId = Convert.ToInt64(activityDropDownList.SelectedValue);
                newProjectDetailActivitySchedule.StartDate       = startDateTime;
                newProjectDetailActivitySchedule.EndDate         = endDateTime;
                newProjectDetailActivitySchedule.OperationTypeId = (int)EnumProjectDetailActivityScheduleOperationType.Insert;

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

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

            if (e.CommandName == "Update")
            {
                RadDropDownList activityDropDownList = (RadDropDownList)e.Container.FindControl("ActivityList");

                RadTimePicker startTime = (RadTimePicker)e.Container.FindControl("StartTime");
                RadTimePicker endTime   = (RadTimePicker)e.Container.FindControl("EndTime");

                var selectedDate = e.Container.Appointment.Start;

                DateTime startDateTime = new DateTime(selectedDate.Year, selectedDate.Month, selectedDate.Day, startTime.SelectedTime.Value.Hours, startTime.SelectedTime.Value.Minutes, startTime.SelectedTime.Value.Seconds);
                DateTime endDateTime   = new DateTime(selectedDate.Year, selectedDate.Month, selectedDate.Day, endTime.SelectedTime.Value.Hours, endTime.SelectedTime.Value.Minutes, endTime.SelectedTime.Value.Seconds);

                var existingProjectDetailActivitySchedule = new UpdateProjectDetailActivityScheduleDTO();
                existingProjectDetailActivitySchedule.ProjectDetailActivityScheduleId = Convert.ToInt64(e.Container.Appointment.ID.ToString());
                existingProjectDetailActivitySchedule.ProjectDetailId         = Convert.ToInt64(ProjectDetailName.SelectedValue);
                existingProjectDetailActivitySchedule.ProjectDetailActivityId = Convert.ToInt64(activityDropDownList.SelectedValue);
                existingProjectDetailActivitySchedule.StartDate       = startDateTime;
                existingProjectDetailActivitySchedule.EndDate         = endDateTime;
                existingProjectDetailActivitySchedule.OperationTypeId = (int)EnumProjectDetailActivityScheduleOperationType.Update;

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

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

            InitializeAppointments();
        }