Exemplo n.º 1
0
        public IActionResult UsersNew(string id, string organizationId)
        {
            if (GetUserId() != 0)
            {
                return(Redirect("/Home/Dashboard"));
            }

            int realId = WebUtilities.DecryptId(id, GetUserName(), GetOrganizationId());

            ViewBag.hashedOrganizationId = organizationId;
            if (realId > 0)
            {
                var userModel = operations.User.GetUserById(realId);
                userModel.HashedId = WebUtilities.EncryptId(userModel.Id, GetUserName(), GetOrganizationId());
                return(View(userModel));
            }
            else
            {
                UsersInsertModel model = new UsersInsertModel();
                return(View(model));
            }
        }
Exemplo n.º 2
0
        public int InsertUsers(UsersInsertModel model)
        {
            string sql = "insert into public.\"Users\"(\"UserName\",\"Password\",\"FirstName\",\"LastName\",\"Email\",\"OrganizationId\",\"ActiveStatus\",\"FailedLoginCount\") values (@UserName,@Password,@FirstName,@LastName,@Email,@OrganizationId,@ActiveStatus,@FailedLoginCount) RETURNING \"Id\"";

            return(_connection.ExecuteScalar <int>(sql, model));
        }
Exemplo n.º 3
0
        public IActionResult UsersNew(UsersInsertModel model, string hashedOrganizationId)
        {
            if (GetUserId() != 0)
            {
                return(Redirect("/Home/Dashboard"));
            }
            model.CloseModal = false;
            if (String.IsNullOrEmpty(model.UserName) || String.IsNullOrEmpty(model.FirstName) || String.IsNullOrEmpty(model.LastName) || String.IsNullOrEmpty(model.Email))
            {
                TempData["Notification"] = WebUtilities.InsertNotification("İsim , ad , mail adresi , kullanıcı adı boş geçilemez.");
                return(View(model));
            }

            if (String.IsNullOrEmpty(model.HashedId))
            {
                int returnValue = operations.Organization.CreateOrganization(model);

                List <AddressBindingInsertModel> insertModel = new List <AddressBindingInsertModel>();
                string[] arrAddressBinding = model.AddressBindings.Split(',');
                for (int i = 0; i < arrAddressBinding.Length; i++)
                {
                    insertModel.Add(new AddressBindingInsertModel {
                        Address = arrAddressBinding[i].Trim().Split(':')[0], Port = Convert.ToInt32(arrAddressBinding[i].Trim().Split(':')[1]), OrganizationId = returnValue
                    });
                }

                operations.Organization.InsertAddressBindings(returnValue, insertModel);

                if (returnValue > 0)
                {
                    model.HashedId           = WebUtilities.EncryptId(returnValue, GetUserName(), GetOrganizationId());
                    TempData["Notification"] = WebUtilities.InsertNotification("Organizasyon başarılı bir şekilde eklenmiştir.");
                    model.CloseModal         = true;
                    return(View(model));
                }
                else
                {
                    TempData["Notification"] = WebUtilities.InsertNotification("Ekleme sırasında bir hata oluştu lütfen sistem yöneticisine başvurunuz.");
                    model.CloseModal         = false;
                    return(View(model));
                }
            }
            else
            {
                int realId = WebUtilities.DecryptId(WebUtility.UrlDecode(model.HashedId), GetUserName(), GetOrganizationId());
                if (realId > 0)
                {
                    List <AddressBindingInsertModel> insertModel = new List <AddressBindingInsertModel>();
                    string[] arrAddressBinding = model.AddressBindings.Split(',');
                    for (int i = 0; i < arrAddressBinding.Length; i++)
                    {
                        insertModel.Add(new AddressBindingInsertModel {
                            Address = arrAddressBinding[i].Trim().Split(':')[0], Port = Convert.ToInt32(arrAddressBinding[i].Trim().Split(':')[1]), OrganizationId = realId
                        });
                    }
                    operations.Organization.DeleteAddressBinding(realId);
                    operations.Organization.InsertAddressBindings(realId, insertModel);
                    operations.Organization.UpdateOrganization(model);
                    return(View(model));
                }
                else
                {
                    TempData["Notification"] = WebUtilities.InsertNotification("Hatalı işlem lütfen pencereyi kapatıp tekrar deneyiniz.");
                    model.CloseModal         = false;
                    return(View(model));
                }
            }
            // return View();
        }