Ejemplo n.º 1
0
        public async Task <ActionResult <Catch> > CreateUserCatch(Catch catchMade)
        {
            ApplicationUser user = _userHelper.GetUser();

            catchMade.Id                = Guid.NewGuid();
            catchMade.LogDate           = DateTime.Now;
            catchMade.EditDate          = DateTime.Now;
            catchMade.CatchNumber       = _fokkersDbService.GetCatchNumberCount(user.Email).Result + 1;
            catchMade.GlobalCatchNumber = _fokkersDbService.GetGlobalCatchNumberCount().Result + 1;
            catchMade.UserEmail         = user.Email;

            CatchData newCatch = new CatchData();

            newCatch.CatchDate         = catchMade.CatchDate.ToUniversalTime();
            newCatch.CatchNumber       = catchMade.CatchNumber;
            newCatch.EditDate          = catchMade.EditDate.ToUniversalTime();
            newCatch.Fish              = catchMade.Fish;
            newCatch.GlobalCatchNumber = catchMade.GlobalCatchNumber;
            newCatch.Length            = catchMade.Length;
            newCatch.LogDate           = catchMade.LogDate.ToUniversalTime();
            newCatch.RowKey            = catchMade.Id.ToString();
            newCatch.UserEmail         = catchMade.UserEmail;
            newCatch.Status            = CatchStatusEnum.Pending;

            await _fokkersDbService.AddItemAsync(newCatch);

            return(CreatedAtAction(nameof(GetByIdUser), new { id = catchMade.Id }, catchMade));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <Catch> > PutAdmin(Guid id, Catch catchMade)
        {
            ApplicationUser user = _userHelper.GetUser();

            catchMade.UserEmail = user.Email;
            catchMade.EditDate  = DateTime.Now;

            CatchData updateCatch = await _fokkersDbService.GetItemAsync(id.ToString());

            updateCatch.CatchDate           = catchMade.CatchDate.ToUniversalTime();
            updateCatch.CatchNumber         = catchMade.CatchNumber;
            updateCatch.EditDate            = catchMade.EditDate.ToUniversalTime();
            updateCatch.Fish                = catchMade.Fish;
            updateCatch.GlobalCatchNumber   = catchMade.GlobalCatchNumber;
            updateCatch.Length              = catchMade.Length;
            updateCatch.LogDate             = catchMade.LogDate.ToUniversalTime();
            updateCatch.UserEmail           = catchMade.UserEmail;
            updateCatch.CatchPhotoUrl       = catchMade.CatchPhotoUrl;
            updateCatch.CatchThumbnailUrl   = catchMade.CatchThumbnailUrl;
            updateCatch.MeasurePhotoUrl     = catchMade.MeasurePhotoUrl;
            updateCatch.MeasureThumbnailUrl = catchMade.MeasureThumbnailUrl;
            updateCatch.Status              = catchMade.Status;

            await _fokkersDbService.UpdateItemAsync(updateCatch);

            return(catchMade);
        }
Ejemplo n.º 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            CatchData catchData = db.CatchDatas.Find(id);

            db.CatchDatas.Remove(catchData);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "Date,FishName,weight,Bait,BaitColor")] CatchData catchData)
 {
     if (ModelState.IsValid)
     {
         db.Entry(catchData).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(catchData));
 }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "Date,FishName,weight,Bait,BaitColor")] CatchData catchData)
        {
            if (ModelState.IsValid)
            {
                db.CatchDatas.Add(catchData);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(catchData));
        }
Ejemplo n.º 6
0
        // GET: CatchDatas/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CatchData catchData = db.CatchDatas.Find(id);

            if (catchData == null)
            {
                return(HttpNotFound());
            }
            return(View(catchData));
        }
Ejemplo n.º 7
0
        public async Task <ActionResult <Catch> > GetByIdUser(Guid id)
        {
            ApplicationUser user      = _userHelper.GetUser();
            CatchData       catchMade = await _fokkersDbService.GetUserItemAsync(id.ToString(), user.Email);

            if (catchMade == null)
            {
                return(NotFound());
            }
            else
            {
                if (catchMade.UserEmail == user.Email)
                {
                    return(catchMade.GetCatch());
                }
                else
                {
                    return(Forbid());
                }
            }
        }
Ejemplo n.º 8
0
 // Catches
 public async Task AddItemAsync(CatchData item)
 {
     await this._catchContainer.AddEntityAsync <CatchData>(item);
 }
Ejemplo n.º 9
0
 public async Task UpdateItemAsync(CatchData item)
 {
     await this._catchContainer.UpdateEntityAsync <CatchData>(item, item.ETag);
 }