예제 #1
0
        public ActionResult BrisiUplatu(int id)
        {
            //this.repo.find("Dokument?entitet=" + entitet + "&entitetopis=" + entitetoipis + "&entitetid" + entitet)
            try
            {
                var obj = _session.Load <Uplata>(id);
                obj.Obrisan = true;
                _session.SaveOrUpdate(obj);
                _session.Flush();
                return(Json(new { Success = true, Message = "", obj = true }));
            }

            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(Json(new { Success = false, Message = ex.Message }));
            }
        }
예제 #2
0
        public async Task <IActionResult> Register(RegisterUserModel model)
        {
            if (ModelState.IsValid)
            {
                //
                // Verify if exists other user with the same username.
                //
                var existUser = await session.Query <User>().FirstOrDefaultAsync(item => item.Username.ToLower() == model.Username.ToLower());

                if (existUser == null)
                {
                    //
                    // Save the user data.
                    //
                    var user = new User
                    {
                        Username = model.Username,
                        Password = model.Password,
                        UserRole = UserRoles.SimpleUser,
                        Email    = model.Email,
                        //
                        Address = new Address
                        {
                            Country   = session.Load <Country>(model.Address.CountryId),
                            Fax       = model.Address.Fax,
                            FirstName = model.Address.FirstName,
                            LastName  = model.Address.LastName,
                            Phone     = model.Address.Phone,
                            Street    = model.Address.Street,
                            Town      = model.Address.Town,
                            ZipCode   = model.Address.ZipCode
                        }
                    };
                    //
                    await session.SaveAsync(user);

                    //
                    // Go to RegisterFinalized page!
                    //
                    return(View("RegisterFinalized"));
                }
                else
                {
                    //
                    // Exists other user with the same username, so show the error message.
                    //
                    var localizedMessages = await localizer.GetLocalizedStringsAsync();

                    ModelState.AddModelError("", localizedMessages["The username is already taken"]);
                }
            }
            await PrepareModel(model);

            return(View(model));
        }
예제 #3
0
 public T Load <T>(object pk) where T : class
 {
     NH.ISession session = Session;
     return(session.Load <T>(pk));
 }