コード例 #1
0
        public async Task <IHttpActionResult> PostIntimacy(Intimacy intimacy)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Intimacies.Add(intimacy);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (IntimacyExists(intimacy.UserID1))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = intimacy.UserID1 }, intimacy));
        }
コード例 #2
0
        public async Task <IHttpActionResult> PutIntimacy(string id, Intimacy intimacy)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != intimacy.UserID1)
            {
                return(BadRequest());
            }

            db.Entry(intimacy).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!IntimacyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public ActionResult Edit(Intimacy model)
        {
            //validate that list stays in the same place
            //id#1 when edit gets moved to the bottom of list
            var confirmEdit = _repo.UpdateIntimacy(model);

            return(RedirectToAction("List"));
        }
コード例 #4
0
 public void LoadIntimacy(Intimacy i)
 {
     intimacy                = i;
     nameField.text          = intimacy.Name;
     contextField.text       = intimacy.Context;
     intensityDropdown.value = (int)intimacy.Intensity;
     intensityDropdown.RefreshShownValue();
 }
コード例 #5
0
 public void AddIntimacy(Intimacy i)
 {
     if (!intimacies.Contains(i))
     {
         intimacies.Add(i);
     }
     //handle new intimacy
 }
コード例 #6
0
        public bool DeleteIntimacy(int intimacyId)
        {
            Intimacy intimacy = GetIntimacyById(intimacyId);

            if (intimacy != null)
            {
                _ctx.Entry(intimacy).State = System.Data.Entity.EntityState.Deleted;
                _ctx.SaveChanges();
            }
            return(true);
        }
コード例 #7
0
        public async Task <IHttpActionResult> GetIntimacy(string id)
        {
            Intimacy intimacy = await db.Intimacies.FindAsync(id);

            if (intimacy == null)
            {
                return(NotFound());
            }

            return(Ok(intimacy));
        }
コード例 #8
0
    public void AddNewIntimacy()
    {
        GameObject newIntimacyUI = Instantiate(IntimacyPrefab);

        newIntimacyUI.transform.SetParent(IntimacyHolder.transform);
        IntimacyUI intUI       = newIntimacyUI.GetComponent <IntimacyUI> ();
        Intimacy   newIntimacy = new Intimacy();

        intUI.intimacy = newIntimacy;
        //characterManager.character.AddIntimacy (newIntimacy);
        intUI.AddCallbacks();
    }
コード例 #9
0
 public int AddIntimacy(Intimacy intimacy)
 {
     if (_intimacies.Count <= 0)
     {
         intimacy.IntimacyId = 1;
     }
     else
     {
         intimacy.IntimacyId = _intimacies.Max(c => c.IntimacyId) + 1;
     }
     _intimacies.Add(intimacy);
     return(intimacy.IntimacyId);
 }
コード例 #10
0
        public async Task <IHttpActionResult> DeleteIntimacy(string id)
        {
            Intimacy intimacy = await db.Intimacies.FindAsync(id);

            if (intimacy == null)
            {
                return(NotFound());
            }

            db.Intimacies.Remove(intimacy);
            await db.SaveChangesAsync();

            return(Ok(intimacy));
        }
コード例 #11
0
        public ActionResult Delete(Intimacy model)
        {
            var confirmDelete = _repo.DeleteIntimacy(model.IntimacyId);

            return(RedirectToAction("List"));
        }
コード例 #12
0
 public ActionResult Add(Intimacy model)
 {
     _repo.AddIntimacy(model);
     return(RedirectToAction("List"));
 }
コード例 #13
0
 public bool UpdateIntimacy(Intimacy intimacy)
 {
     _ctx.Entry(intimacy).State = System.Data.Entity.EntityState.Modified;
     _ctx.SaveChanges();
     return(true);
 }
コード例 #14
0
 public int AddIntimacy(Intimacy intimacy)
 {
     _ctx.Intimacies.Add(intimacy);
     _ctx.SaveChanges();
     return(_ctx.Intimacies.Max(i => i.IntimacyId));
 }
コード例 #15
0
 public bool UpdateIntimacy(Intimacy intimacy)
 {
     _intimacies.RemoveAll(i => i.IntimacyId == intimacy.IntimacyId);
     _intimacies.Add(intimacy);
     return(true);
 }