Пример #1
0
        public void CreateAssociateTest()
        {
            var input = new Associate
            {
                Associate_Id     = 586790,
                Name             = "TestServiceAssociate",
                Email            = "*****@*****.**",
                Mobile           = "1234567890",
                Gender           = "Male",
                Status_Blue      = false,
                Status_Green     = true,
                Status_Red       = false,
                Level_1          = true,
                Level_2          = false,
                Level_3          = false,
                Pic              = "",
                Remark           = "Na",
                Strength         = "Na",
                Other            = "Na",
                Weakness         = "",
                Associate_Skills =
                {
                    new Associate_Skills {
                        Associate_Id = 575566, Rating = 5, Skill_Id = 5
                    },
                    new Associate_Skills {
                        Associate_Id = 575566, Rating = 5, Skill_Id = 6
                    }
                }
            };
            var associate = associatesService.CreateAssociate(input);

            Assert.NotNull(associate);
            Assert.AreEqual(associate.Associate_Id, input.Associate_Id);
        }
Пример #2
0
        public HttpResponseMessage AddAssociate([FromBody] AssociateModel assocaite)
        {
            AssociateModel result = new AssociateModel();

            try
            {
                var alreadyExists = _associatesService.GetAssociate(assocaite.Associate_Id);
                if (alreadyExists == null)
                {
                    var input = Helper.CastObject <Associate>(assocaite);
                    var res   = _associatesService.CreateAssociate(input);
                    result = Helper.CastObject <AssociateModel>(res);
                }
            }
            catch (Exception ex)
            {
                _logManager.WriteLog(ex);
            }
            return(ToJson(result));
        }