예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("TypeId,BranchId,TypeName")] Type mtype)
        {
            if (id != mtype.TypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mtype);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypeExists(mtype.TypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BranchId"] = new SelectList(_context.Branch, "BranchId", "BranchName", mtype.BranchId);
            return(View(mtype));
        }
예제 #2
0
 /// <summary>
 /// Updates the data of the selected type
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public async Task <bool> UpdateType(Type type)
 {
     try
     {
         var response = await(Config.ServiceBase + "update-type").PostJsonAsync(new { data = type });
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
예제 #3
0
        public async Task <IActionResult> CreateType([Bind("TypeId,BranchId,TypeName")] Type mtype, string stringBase64)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mtype);
                await _context.SaveChangesAsync();

                UploadImageTypeFromBase64(stringBase64);
                return(RedirectToAction(nameof(BranchAndTypeListC2C)));
            }
            return(PartialView("_CreateTypeModal", mtype));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("TypeId,BranchId,TypeName")] Type mtype)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mtype);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BranchId"] = new SelectList(_context.Branch, "BranchId", "BranchName", mtype.BranchId);
            return(View(mtype));
        }
예제 #5
0
 /// <summary>
 /// Adds new object type to the database
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public async Task <bool> AddType(Type type)
 {
     try
     {
         type._id = Guid.NewGuid();
         var response = await(Config.ServiceBase + "add-type").PostJsonAsync(new { data = type });
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
예제 #6
0
        public IActionResult CreateType()
        {
            var mtype = new Type();

            return(PartialView("_CreateTypeModal", mtype));
        }