Example #1
0
        public async Task <IActionResult> Edit(Cultivar entity, string id)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Cultivar current_entity = await db.cultivar.byIdAsync(id);

                    entity.id   = getId(id);
                    entity.crop = getId(HttpContext.Request.Form["crop"].ToString());
                    await db.cultivar.updateAsync(current_entity, entity);
                    await writeEventAsync(entity.ToString(), LogEvent.upd);

                    return(RedirectToAction("Index"));
                }
                await writeEventAsync(ModelState.ToString(), LogEvent.err);

                return(View(entity));
            }
            catch (Exception ex)
            {
                await writeExceptionAsync(ex);

                return(View(entity));
            }
        }
Example #2
0
        public async Task <IActionResult> DeleteConfirmed(string id)
        {
            try
            {
                Cultivar entity = await db.cultivar.byIdAsync(id);

                await db.cultivar.deleteAsync(entity);
                await writeEventAsync(entity.ToString(), LogEvent.del);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                await writeExceptionAsync(ex);

                return(RedirectToAction("Delete", new { id = id }));
            }
        }
Example #3
0
        public async Task <IActionResult> Create(Cultivar entity)
        {
            try
            {
                entity.crop = getId(HttpContext.Request.Form["crop"].ToString());
                if (ModelState.IsValid)
                {
                    await db.cultivar.insertAsync(entity);
                    await writeEventAsync(entity.ToString(), LogEvent.cre);

                    return(RedirectToAction("Index"));
                }
                await writeEventAsync(ModelState.ToString(), LogEvent.err);

                return(View(entity));
            }
            catch (Exception ex)
            {
                await writeExceptionAsync(ex);

                return(View(entity));
            }
        }