示例#1
0
        public JsonResult EditChange(ObservationChange model)
        {
            using (Entity context = new Entity())
            {
                try
                {
                    t_observation_change change = context.t_observation_change.Find(model.ChangeId);
                    if (change == null)
                    {
                        throw new ArgumentException("Invalid changeId: " + model.ChangeId.ToString());
                    }

                    change.start_date       = model.StartDate;
                    change.description      = model.Description;
                    change.updatedby_userid = CurrentUser.Id;
                    change.updated_date     = DateTime.Now;
                    context.SaveChanges();

                    context.Entry(change).Reference(n => n.updatedby).Load();

                    return(Json(new
                    {
                        success = true,
                        StartDate = change.start_date.ToString("d"),
                        Description = change.description,
                        UpdatedBy = change.updatedby.full_name,
                        UpdatedOn = change.updated_date.Value.ToString("d")
                    }));
                }
                catch (Exception ex)
                {
                    return(GetJsonResult(ex));
                }
            }
        }
 public ChangePage(ObservationChange change = null)
 {
     InitializeComponent();
     if (Device.OS == TargetPlatform.Android)
     {
         BoxView.IsVisible = false;
     }
     buttonLayout.BackgroundColor = Color.FromHex("#034468");
     NavigationPage.SetBackButtonTitle(this, "Cancel");
     if (change == null)
     {
         _change = new ObservationChange {
             Start_Date = DateTime.Now
         };
     }
     else
     {
         _change = change;
     }
     ViewModel.Change         = _change;
     ViewModel.OriginalChange = _change;
 }
示例#3
0
        public JsonResult AddChange(ObservationChange model)
        {
            using (Entity context = new Entity())
            {
                try
                {
                    t_observation_change change = new t_observation_change();
                    change.observation_id   = model.ObservationId;
                    change.start_date       = model.StartDate;
                    change.description      = model.Description;
                    change.createdby_userid = CurrentUser.Id;
                    change.created_date     = DateTime.Now;
                    change.approved         = true; // all changes automatically approved
                    context.t_observation_change.Add(change);
                    context.SaveChanges();


                    context.Entry(change).Reference(n => n.createdby).Load();

                    return(Json(new
                    {
                        success = true,
                        ChangeId = change.observation_change_id,
                        ObservationId = change.observation_id,
                        StartDate = change.start_date.ToString("d"),
                        Description = change.description,
                        CreatedBy = change.createdby.full_name,
                        CreatedOn = change.created_date.ToString("d")
                    }));
                }
                catch (Exception ex)
                {
                    return(GetJsonResult(ex));
                }
            }
        }
示例#4
0
 public async void OnChangeItemTapped(object sender, ItemTappedEventArgs e)
 {
     ObservationChange change = (ObservationChange)e.Item;
     //await Navigation.PushAsync(new ObservationPage(indicator, _site));
     await Navigation.PushModalAsync(new ChangePage(change));
 }