Esempio n. 1
0
 public SaveResponseBuilder(ISession session, User user, SaveRequest saveRequest, string @group)
 {
     this.session = session;
     this.user = user;
     this.saveRequest = saveRequest;
     this.group = group;
 }
Esempio n. 2
0
        public void AdministratorAddMany()
        {
            // Arrange
            var administrator = new Persons(this.Session).FindBy(Persons.Meta.UserName, Users.AdministratorUserName);

            var c1a = new C1Builder(this.Session)
               .Build();

            var c1b = new C1Builder(this.Session)
               .Build();

            var c1c = new C1Builder(this.Session)
               .Build();

            c1a.AddC1C1One2Many(c1b);

            this.Session.Derive();
            this.Session.Commit();

            var saveRequest = new SaveRequest
            {
                Objects = new[] {
                    new SaveRequestObject
                    {
                        I = c1a.Id.ToString(),
                        V = c1a.Strategy.ObjectVersion.ToString(),
                        Roles = new List<SaveRequestRole>
                        {
                            new SaveRequestRole
                            {
                                T = "C1C1One2Many",
                                A = new [] { c1c.Id.ToString() }
                            }
                        }
                    }
                }
            };

            var controller = new AngularController { AllorsSession = this.Session, AuthenticatedUser = administrator };

            // Act
            var jsonResult = (JsonResult)controller.Save(saveRequest);
            var saveResponse = (SaveResponse)jsonResult.Data;

            // Assert
            this.Session.Rollback();

            saveResponse.Errors.Count.ShouldEqual(0);

            c1a.C1C1One2Manies.ShouldNotBeSameAs(new[] { c1b, c1c });
        }
Esempio n. 3
0
 public ActionResult Save(SaveRequest saveRequest)
 {
     try
     {
         var user = this.AuthenticatedUser ?? Singleton.Instance(this.AllorsSession).Guest;
         var saveResponseBuilder = new SaveResponseBuilder(this.AllorsSession, user, saveRequest, Group);
         return JsonSuccess(saveResponseBuilder.Build());
     }
     catch (Exception e) { return JsonError(e.Message); }
 }
Esempio n. 4
0
        public void GuestSetUnit()
        {
            // Arrange
            var c1a = new C1Builder(this.Session)
               .WithC1AllorsString("c1")
               .WithI1AllorsString("i1")
               .WithI12AllorsString("i12")
               .Build();

            this.Session.Derive();
            this.Session.Commit();

            var saveRequest = new SaveRequest
            {
                Objects = new[] {
                    new SaveRequestObject
                    {
                        I = c1a.Id.ToString(),
                        V = c1a.Strategy.ObjectVersion.ToString(),
                        Roles = new List<SaveRequestRole>
                        {
                            new SaveRequestRole
                            {
                                T = "C1AllorsString",
                                S = "new c1"
                            }
                        }
                    }
                }
            };

            var controller = new AngularController { AllorsSession = this.Session };

            // Act
            var jsonResult = (JsonResult)controller.Save(saveRequest);
            var saveResponse = (SaveResponse)jsonResult.Data;

            // Assert
            this.Session.Rollback();

            saveResponse.Errors.Count.ShouldEqual(1);

            c1a.C1AllorsString.ShouldEqual("c1");
        }