Esempio n. 1
0
        public async Task <IActionResult> Create(SuObjectAndStatusViewModel FromForm)
        {
            if (ModelState.IsValid)
            {
                var Organization = new SuOrganizationModel
                {
                    ModifiedDate         = DateTime.Now,
                    CreatedDate          = DateTime.Now,
                    OrganizationStatusId = FromForm.SuObject.Status,
                    OrganizationTypeId   = FromForm.SuObject.Type
                };
                if (FromForm.SuObject.NullId != 0)
                {
                    Organization.ParentOrganizationId = FromForm.SuObject.NullId;
                }
                var NewOrganization = _Organization.AddOrganization(Organization);


                var CurrentUser = await _userManager.GetUserAsync(User);

                SuOrganizationLanguageModel OrganizationLanguage = new SuOrganizationLanguageModel
                {
                    Name           = FromForm.SuObject.Name,
                    Description    = FromForm.SuObject.Description,
                    MouseOver      = FromForm.SuObject.MouseOver,
                    OrganizationId = NewOrganization.Id,
                    LanguageId     = CurrentUser.DefaultLanguageId
                };
                _OrganizationLanguage.AddOrganizationLanguage(OrganizationLanguage);
            }
            return(RedirectToAction("Index"));
        }