public WebResponseContentModel <EventMeetingModel> SaveEventMeetingChanges(EventMeetingModel newData)
        {
            WebResponseContentModel <EventMeetingModel> model = new WebResponseContentModel <EventMeetingModel>();

            try
            {
                model.Content = newData;
                model         = PostWebRequestData <WebResponseContentModel <EventMeetingModel> >(WebServiceHelper.SaveEventMeetingChanges(), "post", model);
            }
            catch (Exception ex)
            {
                model.ValidationErrorAppSide = ConcatenateExceptionMessage(ex);
            }

            return(model);
        }
        /// <summary>
        /// Add new EventMeetingModel instance to event model session
        /// </summary>
        /// <param name="model">New EventMeetingModel instance to add</param>
        /// <returns>Returns true if adding was succesfull. Otherwise false.</returns>
        public bool AddEventMeetingToEventModelSession(EventMeetingModel model)
        {
            EventFullModel fullModel = GetEventFullModel();

            if (fullModel != null)
            {
                if (fullModel.SestanekDokumenti == null)
                {
                    fullModel.SestanekDokumenti = new List <EventMeetingModel>();
                }

                fullModel.SestanekDokumenti.Add(model);
                AddValueToSession(Enums.EventSession.EventModel, fullModel);

                return(true);
            }
            return(false);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //ComboBoxKategorije.DataBind();
         if (action == (int)Enums.UserAction.Edit || action == (int)Enums.UserAction.Delete)
         {
             if (eventMeetingID > 0 && eventMeetingID > 0)
             {
                 model = GetEventDataProviderInstance().GetEventMeetingFromEventModelSession(eventMeetingID, eventID);
                 FillForm();
             }
         }
         else if (action == (int)Enums.UserAction.Add)//acion ADD
         {
             //txtIdStranke.Text = clientID.ToString();
             // ComboBoxKategorije.SelectedIndex = 0;
         }
         UserActionConfirmBtnUpdate(btnConfirmPopUp, action, true);
     }
 }
        public int SaveEventMeeting(EventMeetingModel model, bool updateRecord = true)
        {
            try
            {
                DogodekSestanek eventMeeting = new DogodekSestanek();

                eventMeeting.DogodekSestanekID = model.DogodekSestanekID;
                eventMeeting.DogodekID         = model.DogodekID;
                eventMeeting.Tip       = model.Tip;
                eventMeeting.Datum     = model.Datum;
                eventMeeting.Opis      = model.Opis;
                eventMeeting.ts        = DateTime.Now;
                eventMeeting.tsIDOsebe = model.tsIDOsebe;

                if (eventMeeting.DogodekSestanekID == 0)
                {
                    context.DogodekSestanek.Add(eventMeeting);
                    context.SaveChanges();
                }
                else
                {
                    if (updateRecord)
                    {
                        DogodekSestanek original = context.DogodekSestanek.Where(ds => ds.DogodekSestanekID == eventMeeting.DogodekSestanekID).FirstOrDefault();
                        context.Entry(original).CurrentValues.SetValues(eventMeeting);
                        context.SaveChanges();
                    }
                }

                return(eventMeeting.DogodekSestanekID);
            }
            catch (Exception ex)
            {
                throw new Exception(ValidationExceptionError.res_08, ex);
            }
        }
Exemplo n.º 5
0
        protected void CallbackPanelMeeting_Callback(object sender, CallbackEventArgsBase e)
        {
            switch (e.Parameter)
            {
            case "2":
            {
                object valueID = null;
                if (ASPxGridView_Sestanek.VisibleRowCount > 0)
                {
                    valueID = ASPxGridView_Sestanek.GetRowValues(ASPxGridView_Sestanek.FocusedRowIndex, "DogodekSestanekID");
                }

                bool isValid1 = SetSessionsAndOpenPopUp(e.Parameter, Enums.EventSession.EventMeetingID, valueID);
                SetSessionsAndOpenPopUp(e.Parameter, Enums.EventSession.EventStatusID, model.idStatus);
                if (isValid1)
                {
                    ASPxEventMeetingNotes.ShowOnPageLoad = true;
                }
            }
            break;

            case "RefreshGrid":
                ASPxGridView_Sestanek.DataBind();
                break;

            default:
                bool isValid = false;
                if (action == (int)Enums.UserAction.Add)
                {
                    isValid = AddOrEditEntityObject(true);
                }

                EventMeetingModel modelNew = new EventMeetingModel();
                modelNew.DogodekID = GetEventDataProviderInstance().GetEventFullModel().idDogodek;
                modelNew.Datum     = DateTime.Now;
                modelNew.tsIDOsebe = PrincipalHelper.GetUserPrincipal().ID;

                if (e.Parameter.Equals(Enums.EventMeetingType.PRIPRAVA.ToString()))
                {
                    modelNew.Opis = htmlPriprava.Html;
                    modelNew.Tip  = Enums.EventMeetingType.PRIPRAVA.ToString();
                }
                else if (e.Parameter.Equals(Enums.EventMeetingType.POROCILO.ToString()))
                {
                    modelNew.Opis = htmlPorocilo.Html;
                    modelNew.Tip  = Enums.EventMeetingType.POROCILO.ToString();
                }

                EventMeetingModel newModel = CheckModelValidation(GetDatabaseConnectionInstance().SaveEventMeetingChanges(modelNew));
                if (newModel != null)
                {
                    GetEventDataProviderInstance().AddEventMeetingToEventModelSession(newModel);
                }
                else
                {
                    ShowClientPopUp("Commit save failed");
                }


                if (isValid)
                {
                    int idEvent = GetEventDataProviderInstance().GetEventFullModel().idDogodek;
                    AddValueToSession(Enums.CommonSession.ShowWarning, true);
                    ASPxWebControl.RedirectOnCallback(GenerateURI("EventsForm.aspx", (int)Enums.UserAction.Edit, idEvent.ToString()));
                }
                else
                {
                    ASPxGridView_Sestanek.DataBind();
                }
                break;
            }
        }