Пример #1
0
        public IActionResult EditSightseen(SightseenModel ssm)
        {
            Sightseen ss = appCtx.Sightseens.FirstOrDefault(s => s.Id == ssm.Id);

            if (ss != null)
            {
                ss.Name  = ssm.Name == null ? ss.Name : ssm.Name;
                ss.Point = new Point {
                    X = ssm.X == null? ss.Point.X : (float)ssm.X, Y = ssm.Y == null ? ss.Point.Y : (float)ssm.Y
                };
                ss.Discription         = ssm.Discription == null ? ss.Discription : ssm.Discription;
                appCtx.Entry(ss).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                appCtx.SaveChanges();
                return(Ok());
            }
            return(BadRequest(new { errorText = "Invalid SightseenId" }));
        }
Пример #2
0
        public IActionResult AddSightseen([FromBody] SightseenModel ssm)
        {
            Sightseen ss = new Sightseen
            {
                BaseRate    = 0,
                Count       = 0,
                Discription = ssm.Discription,
                ImagePath   = ssm.ImagePath,
                Name        = ssm.Name,
                Point       = new Point {
                    X = (float)ssm.X, Y = (float)ssm.Y
                },
                Type = "sightseen"
            };

            appCtx.Sightseens.Add(ss);
            appCtx.SaveChanges();
            return(Ok());
        }